Messages : 51
Sujets : 2
Inscription : Jun 2024
Réputation :
7
04-07-2024, 09:01 PM
(Modification du message : 05-07-2024, 02:13 PM par Raphael591.
Raison de la modification: Reprise des images
)
Bonjour,
J'ai modifié mon affichage (SSD1306), je mets à dispo pour ceux qui souhaites le récupérer.
Devrait s'adapter automatiquement si vous n'avez pas de triac mais un relais.
Voir commentaires pour ceux en SH110X si j'ai rien oublié.
Ecran 2 inchangé (Injection jour).
Ajout d'un 3ème affichage pour l'équivalence nombre d'heure d'ouverture 100 % :
Fichier OLED.ino : https://uploadnow.io/s/e28214e3-379e-410...4ca53e81ef
A+
Routeur avec Triac, CE 2500w. Shelly pro em50 pour les mesures. Kit PV pnp 2 kW. Home assistant
Messages : 668
Sujets : 22
Inscription : May 2024
Réputation :
70
Bien
Il ne me reste plus qu'à l'intégrer définitivement dans une prochaine version.
André
Messages : 84
Sujets : 9
Inscription : Jun 2024
Réputation :
3
05-07-2024, 08:48 AM
(Modification du message : 09-07-2024, 10:53 AM par lucky.)
Bonjour,
encore une fois merci pour ce super travail
voici adapté a un afficheur SH110X
Code : /***********************************
AFFICHAGE SUR SH110X
*************************************/
#include <Adafruit_GFX.h>
//#include <Adafruit_SSD1306.h>
//Pour écran SH110X
#include <Adafruit_SH110X.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
// Définir les broches SDA et SCL personalisées
#define SDA_PIN 33
#define SCL_PIN 32
bool OLED_on = false; //Si problème avec l'écran, les procédures sont ignorées
int MATERIEL_ROUTAGE=-1; //Pour la recherche TRIAC OU RELAIS
//Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//Pour écran SH110X
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const unsigned char bitmap_Sun[] PROGMEM = {
0x00,0x00, // ................
0x20,0x82, // ..#.....#.....#.
0x10,0x84, // ...#....#....#..
0x08,0x08, // ....#.......#...
0x01,0xC0, // .......###......
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x0F,0xF8, // ....#########...
0x6F,0xFB, // .##.#########.##
0x0F,0xF8, // ....#########...
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x11,0xC4, // ...#...###...#..
0x20,0x02, // ..#...........#.
0x40,0x81, // .#......#......#
0x00,0x80 // ........#.......
};
const unsigned char bitmap_Off[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x1F,0xF8, // ...##########...
0x1F,0xF8, // ...##########...
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
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, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x40,0x00, // .#..............
0xC0,0x00, // ##..............
0xC0,0x00 // ##..............
};
const unsigned char bitmap_Signal2[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x04,0x00, // .....#..........
0x0C,0x00, // ....##..........
0x1C,0x00, // ...###..........
0x1C,0x00, // ...###..........
0x5C,0x00, // .#.###..........
0xDC,0x00, // ##.###..........
0xDC,0x00 // ##.###..........
};
const unsigned char bitmap_Signal3[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x40, // .........#......
0x00,0xC0, // ........##......
0x01,0xC0, // .......###......
0x01,0xC0, // .......###......
0x05,0xC0, // .....#.###......
0x0D,0xC0, // ....##.###......
0x1D,0xC0, // ...###.###......
0x1D,0xC0, // ...###.###......
0x5D,0xC0, // .#.###.###......
0xDD,0xC0, // ##.###.###......
0xDD,0xC0 // ##.###.###......
};
const unsigned char bitmap_Signal4[] PROGMEM = {
0x00,0x00, // ................
0x00,0x04, // .............#..
0x00,0x0C, // ............##..
0x00,0x1C, // ...........###..
0x00,0x1C, // ...........###..
0x00,0x5C, // .........#.###..
0x00,0xDC, // ........##.###..
0x01,0xDC, // .......###.###..
0x01,0xDC, // .......###.###..
0x05,0xDC, // .....#.###.###..
0x0D,0xDC, // ....##.###.###..
0x1D,0xDC, // ...###.###.###..
0x1D,0xDC, // ...###.###.###..
0x5D,0xDC, // .#.###.###.###..
0xDD,0xDC, // ##.###.###.###..
0xDD,0xDC // ##.###.###.###..
};
const unsigned char bitmap_Signal0[] PROGMEM = {
0x00,0x00, // ................
0x03,0xE0, // ......#####.....
0x0F,0xF8, // ....#########...
0x1F,0xFC, // ...###########..
0x3E,0x3E, // ..#####...#####.
0x38,0x7E, // ..###....######.
0x70,0xFF, // .###....########
0x71,0xF7, // .###...#####.###
0x73,0xC7, // .###..####...###
0x77,0x87, // .###.####....###
0x3F,0x0E, // ..######....###.
0x3E,0x1E, // ..#####....####.
0x1F,0xFC, // ...###########..
0x0F,0xF8, // ....#########...
0x03,0xE0, // ......#####.....
0x00,0x00 // ................
};
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 // ................................................................................................................................
};
int cligSun = 0;
int BoucleOled = 0;
void InitSSD(){
//OLED init
Wire.begin(SDA_PIN, SCL_PIN);
pinMode (OLED_RESET, OUTPUT);
//FORCE RESET DE L'ECRAN SI PIN PARTICULIER POUR RESET
if(OLED_RESET != -1) {
digitalWrite(OLED_RESET, HIGH);
digitalWrite(OLED_RESET, LOW);
delay(100);
}
if (!display.begin(SCREEN_ADDRESS, true)){//if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { //if (!display.begin(SCREEN_ADDRESS, true)) { //Pour SH110X
Serial.println("OLED init failed");
}
else {
//Allumer l'écran.
//display.ssd1306_command(SSD1306_DISPLAYON); //Commenter pour SH110X
OledLogo();
display.setCursor(70,50);
display.print(F("Init..."));
display.display();
OLED_on=true;
}
//
}
void OledAffiche(){
if(OLED_on==false) {
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
display.clearDisplay();
BarreEtatDroite();
Ecran1();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 14 ) {
//Ecran 2
display.clearDisplay();
Ecran2();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 18 ) {
//Ecran 3
display.clearDisplay();
Ecran3();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 20 ) {
OledLogo();
BoucleOled++;
}
else {
BoucleOled=0;
}
}
void Ecran1(){
if(OLED_on==false) {
return;
}
display.setTextSize(1);
//display.setTextColor(WHITE);
display.setTextColor(SH110X_WHITE); //SH110X
//WIFI
display.setCursor(0,5);
if (WiFi.status() == WL_CONNECTED) {
display.print(WiFi.localIP().toString());
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.print(WiFi.softAPIP().toString()) : display.print(F("Pas de wifi !"));
}
//Ligne de séparation
display.drawLine(0,18,128,18,SH110X_WHITE);
//Puissance sonde maison
display.setCursor(0,24);
display.println(F("Puissance"));
display.setCursor(0,37);
display.setTextSize(2);
display.print(int(PuissanceS_M - PuissanceI_M));
display.setTextSize(1);
//Ouverture du triac/ssr
int Ouv = -1;
if(MATERIEL_ROUTAGE != -1) {
Ouv = 100 - Retard[MATERIEL_ROUTAGE];
}
if(Ouv>0) {
//Icone clignote, signale le routage
if(cligSun==0) {
display.drawBitmap(92, 1, bitmap_Sun , 16, 16, SH110X_WHITE);
cligSun=1;
}
else {
cligSun=0;
display.drawBitmap(92, 1, bitmap_Off , 16, 16, SH110X_WHITE);
}
}
else {
//Pas de triac/relais...
}
display.setCursor(0,38);
if(Ouv == -1) {
display.setCursor(82,24);
display.print(F("Ouv")); //Triac erreur
display.drawRect(70, 24, 10, 30, SH110X_WHITE);
display.setCursor(82,38);
display.print(F(" !"));
}
else {
//Affiche jauge Triac/Relais
display.setCursor(82,24);
display.print(F("Ouv"));
display.drawRect(70, 24, 10, 30, SH110X_WHITE);
float t = (float(30)/100)*Ouv;
display.fillRect(70+2, 24+(30-int(t)), 10-4 , int(t), SH110X_WHITE);
display.setTextSize(1);
display.setCursor(83,38);
display.print(Ouv);
display.print(F("%"));
}
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(108-(durOn.length()*6),57);
display.print(durOn);
}
void BarreEtatDroite() { /*Affiche une barre d'état WIFI et mode action*/
if(OLED_on==false) {
return;
}
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.drawLine(110,18,110,64,SH110X_WHITE); //Ligne séparatrice à droite
//Niveau Wifi
if (WiFi.status() == WL_CONNECTED) {
//Icone niveau connection
int NivSignal = int(WiFi.RSSI()) ;
if (NivSignal<-80) {display.drawBitmap(112, 0, bitmap_Signal1 , 16, 16, SH110X_WHITE); }
else if(NivSignal<-60) {display.drawBitmap(112, 0, bitmap_Signal2 , 16, 16, SH110X_WHITE); }
else if(NivSignal<-45) {display.drawBitmap(112, 0, bitmap_Signal3 , 16, 16, SH110X_WHITE); }
else if(NivSignal<-30) {display.drawBitmap(112, 0, bitmap_Signal4 , 16, 16, SH110X_WHITE); }
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, SH110X_WHITE) : display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, SH110X_WHITE);
}
//Mode en cours du Triac/ssr...
int Mode = 0;
if (MATERIEL_ROUTAGE != -1) Mode = LesActions[MATERIEL_ROUTAGE].TypeEnCours(HeureCouranteDeci, temperature, LTARFbin);
display.setCursor(115,21);
display.setTextColor(SH110X_WHITE);
if(Mode!=1){
display.print(F("OF"));
}
else {
display.fillRect(114,20,13,10,SH110X_WHITE);
display.setTextColor(SH110X_BLACK);
display.print(F("OF"));
}
display.setCursor(115,33);
display.setTextColor(SH110X_WHITE);
if(Mode!=2){
display.print(F("ON"));
}
else {
display.fillRect(114,32,13,10,SH110X_WHITE);
display.setTextColor(SH110X_BLACK);
display.print(F("ON"));
}
display.setCursor(115,45);
display.setTextColor(SH110X_WHITE);
if(Mode!=3){
display.print(F("PW"));
}
else {
display.fillRect(114,44,13,10,SH110X_WHITE);
display.setTextColor(SH110X_BLACK);
display.print(F("PW"));
}
display.setCursor(115,57);
display.setTextColor(SH110X_WHITE);
if(Mode!=4){
display.print(F("TR"));
}
else {
display.fillRect(114,56,13,10,SH110X_WHITE);
display.setTextColor(SH110X_BLACK);
display.print(F("TR"));
}
display.setTextColor(SH110X_WHITE);
}
void Ecran2() {
if(OLED_on==false){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(SH110X_WHITE);
display.println(F("Injectee"));
display.println(F("jour"));
display.print(EnergieJour_M_Injectee);
display.print(F(" Wh"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,55);
display.print(F("V "));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+" h";
display.setCursor(128-(durOn.length()*6),55);
display.print(durOn);
}
void Ecran3() {
if(OLED_on==false){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(SH110X_WHITE);
float H = 0;
if(MATERIEL_ROUTAGE != -1 ) H = H_Ouvre[MATERIEL_ROUTAGE];
display.println(F("Heure"));
display.println(F("router"));
display.print(H);
display.println(F("h"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(128-(durOn.length()*6),57);
display.print(durOn);
}
void OledLogo() {
display.clearDisplay();
display.setCursor(0,0);
display.drawBitmap(0, 0, bitmap_Logo , 128, 68, SH110X_WHITE);
display.setCursor(70,50);
display.print(F("V "));
display.print(Version);
display.display();
}
il y avait plusieurs ligne a modif de WHITE a SH110X_WHITE
encore merci.....
ESP32Wroom, Triac 40A "BTA40", Source UxIx2, Cumulus 300L 3000W.
Sonde temperature sur radiateur triac mise en route ventilateur a 25°
réactivité 30 seuil -100
14 panneaux de 410wcc en autoconso micro-onduleur APS DS3
200W max d injection sur reseau
Suivi sur Domoticz
Messages : 6
Sujets : 2
Inscription : Jun 2024
Réputation :
0
(04-07-2024, 09:01 PM)Raphael591 a écrit : Bonjour,
J'ai modifié mon affichage (SSD1306), je mets à dispo pour ceux qui souhaites le récupérer.
Devrait s'adapter automatiquement si vous n'avez pas de triac mais un relais.
Voir commentaires pour ceux en SH110X si j'ai rien oublié.
Ecran 2 inchangé (Injection jour).
Ajout d'un 3ème affichage pour l'équivalence nombre d'heure d'ouverture 100 % :
Fichier OLED.ino : https://uploadnow.io/s/e28214e3-379e-410...4ca53e81ef
A+ Super, je vais le tester demain.
Déjà la version 11.11?
Pensez vous pouvoir adapter le code en intégrant un bouton poussoir pour n'allumer l'écran que s'il y a une action sur celui ci?
Merci encore.
Serge
Messages : 51
Sujets : 2
Inscription : Jun 2024
Réputation :
7
(07-07-2024, 09:01 PM)Serge 11 a écrit : Super, je vais le tester demain.
Déjà la version 11.11?
Pensez vous pouvoir adapter le code en intégrant un bouton poussoir pour n'allumer l'écran que s'il y a une action sur celui ci?
Merci encore.
Serge
Bonjour,
Fichier avec gestion d'un bouton poussoir pour extinction/allumage de l'écran.
Il suffit de renseigner le pin sur lequel est branché le bouton, voir commentaire.
Je n'ai pas effectué de tests en réel.
Code : /***********************************
AFFICHAGE SUR SSD1306/SH110X
*************************************/
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//Pour écran SH110X
//#include <Adafruit_SH110X.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
// Définir les broches SDA et SCL personalisées
#define SDA_PIN 26
#define SCL_PIN 25
bool OLED_on = false; //Si problème avec l'écran, les procédures sont ignorées
//*******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=false; //Statut oled On/Off (Off par défault)
volatile bool OledChange=false; //Changement sur bouton, true=extinction ecran démarrage
int pinBtnOled = 0; //Indiquer ici le pin du bouton pour gérer l'écran
//******BOUTON OLED ***********/
int MATERIEL_ROUTAGE=-1; //Pour la recherche TRIAC OU RELAIS
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//Pour écran SH110X
//Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const unsigned char bitmap_Sun[] PROGMEM = {
0x00,0x00, // ................
0x20,0x82, // ..#.....#.....#.
0x10,0x84, // ...#....#....#..
0x08,0x08, // ....#.......#...
0x01,0xC0, // .......###......
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x0F,0xF8, // ....#########...
0x6F,0xFB, // .##.#########.##
0x0F,0xF8, // ....#########...
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x11,0xC4, // ...#...###...#..
0x20,0x02, // ..#...........#.
0x40,0x81, // .#......#......#
0x00,0x80 // ........#.......
};
const unsigned char bitmap_Off[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x1F,0xF8, // ...##########...
0x1F,0xF8, // ...##########...
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
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, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x40,0x00, // .#..............
0xC0,0x00, // ##..............
0xC0,0x00 // ##..............
};
const unsigned char bitmap_Signal2[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x04,0x00, // .....#..........
0x0C,0x00, // ....##..........
0x1C,0x00, // ...###..........
0x1C,0x00, // ...###..........
0x5C,0x00, // .#.###..........
0xDC,0x00, // ##.###..........
0xDC,0x00 // ##.###..........
};
const unsigned char bitmap_Signal3[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x40, // .........#......
0x00,0xC0, // ........##......
0x01,0xC0, // .......###......
0x01,0xC0, // .......###......
0x05,0xC0, // .....#.###......
0x0D,0xC0, // ....##.###......
0x1D,0xC0, // ...###.###......
0x1D,0xC0, // ...###.###......
0x5D,0xC0, // .#.###.###......
0xDD,0xC0, // ##.###.###......
0xDD,0xC0 // ##.###.###......
};
const unsigned char bitmap_Signal4[] PROGMEM = {
0x00,0x00, // ................
0x00,0x04, // .............#..
0x00,0x0C, // ............##..
0x00,0x1C, // ...........###..
0x00,0x1C, // ...........###..
0x00,0x5C, // .........#.###..
0x00,0xDC, // ........##.###..
0x01,0xDC, // .......###.###..
0x01,0xDC, // .......###.###..
0x05,0xDC, // .....#.###.###..
0x0D,0xDC, // ....##.###.###..
0x1D,0xDC, // ...###.###.###..
0x1D,0xDC, // ...###.###.###..
0x5D,0xDC, // .#.###.###.###..
0xDD,0xDC, // ##.###.###.###..
0xDD,0xDC // ##.###.###.###..
};
const unsigned char bitmap_Signal0[] PROGMEM = {
0x00,0x00, // ................
0x03,0xE0, // ......#####.....
0x0F,0xF8, // ....#########...
0x1F,0xFC, // ...###########..
0x3E,0x3E, // ..#####...#####.
0x38,0x7E, // ..###....######.
0x70,0xFF, // .###....########
0x71,0xF7, // .###...#####.###
0x73,0xC7, // .###..####...###
0x77,0x87, // .###.####....###
0x3F,0x0E, // ..######....###.
0x3E,0x1E, // ..#####....####.
0x1F,0xFC, // ...###########..
0x0F,0xF8, // ....#########...
0x03,0xE0, // ......#####.....
0x00,0x00 // ................
};
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 // ................................................................................................................................
};
int cligSun = 0;
int BoucleOled = 0;
//Initialisation
void InitSSD(){
//OLED init
Wire.begin(SDA_PIN, SCL_PIN);
pinMode (OLED_RESET, OUTPUT);
//FORCE RESET DE L'ECRAN SI PIN PARTICULIER POUR RESET
if(OLED_RESET != -1) {
digitalWrite(OLED_RESET, HIGH);
digitalWrite(OLED_RESET, LOW);
delay(100);
}
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { //if (!display.begin(SCREEN_ADDRESS, true)) { //Pour SH110X
Serial.println("OLED init failed");
}
else {
//Allumer l'écran.
display.ssd1306_command(SSD1306_DISPLAYON); //Commenter pour SH110X
//oled_command(SH110X_DISPLAYON); //SH110X
OledLogo();
display.setCursor(70,50);
display.print(F("Init..."));
display.display();
OLED_on=true;
}
//Partie gestion bouton
if(pinBtnOled > 0) {
pinMode(pinBtnOled, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pinBtnOled), OledBouton, RISING) ;
}
}
//Procédure boucle des écrans
void OledAffiche(){
if(OLED_on==false) {
return;
}
if (OledChange) {
OledChange=false; //Changement traité
if(OledState) {
//Allumer écran
display.ssd1306_command(SSD1306_DISPLAYON); //Commenter pour SH110X
//oled_command(SH110X_DISPLAYON); //SH110X
BoucleOled=0; //reprise début boucle écran
}
else {
//Eteindre écran
display.ssd1306_command(SSD1306_DISPLAYOFF); //Commenter pour SH110X
//oled_command(SH110X_DISPLAYOFF); //SH110X
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
display.clearDisplay();
BarreEtatDroite();
Ecran1();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 14 ) {
//Ecran 2
display.clearDisplay();
Ecran2();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 18 ) {
//Ecran 3
display.clearDisplay();
Ecran3();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 20 ) {
OledLogo();
BoucleOled++;
}
else {
BoucleOled=0;
}
}
//contenue écran 1
void Ecran1(){
if(OLED_on==false || !OledState) {
return;
}
display.setTextSize(1);
display.setTextColor(WHITE); //display.setTextColor(SH110X_WHITE); //SH110X
//WIFI
display.setCursor(0,5);
if (WiFi.status() == WL_CONNECTED) {
display.print(WiFi.localIP().toString());
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.print(WiFi.softAPIP().toString()) : display.print(F("Pas de wifi !"));
}
//Ligne de séparation
display.drawLine(0,18,128,18,WHITE);
//Puissance sonde maison
display.setCursor(0,24);
display.println(F("Puissance"));
display.setCursor(0,37);
display.setTextSize(2);
display.print(int(PuissanceS_M - PuissanceI_M));
display.setTextSize(1);
//Ouverture du triac/ssr
int Ouv = -1;
if(MATERIEL_ROUTAGE != -1) {
Ouv = 100 - Retard[MATERIEL_ROUTAGE];
}
if(Ouv>0) {
//Icone clignote, signale le routage
if(cligSun==0) {
display.drawBitmap(92, 1, bitmap_Sun , 16, 16, WHITE);
cligSun=1;
}
else {
cligSun=0;
display.drawBitmap(92, 1, bitmap_Off , 16, 16, WHITE);
}
}
else {
//Pas de triac/relais...
}
display.setCursor(0,38);
if(Ouv == -1) {
display.setCursor(82,24);
display.print(F("Ouv")); //Triac erreur
display.drawRect(70, 24, 10, 30, WHITE);
display.setCursor(82,38);
display.print(F(" !"));
}
else {
//Affiche jauge Triac/Relais
display.setCursor(82,24);
display.print(F("Ouv"));
display.drawRect(70, 24, 10, 30, WHITE);
float t = (float(30)/100)*Ouv;
display.fillRect(70+2, 24+(30-int(t)), 10-4 , int(t), WHITE);
display.setTextSize(1);
display.setCursor(83,38);
display.print(Ouv);
display.print(F("%"));
}
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(108-(durOn.length()*6),57);
display.print(durOn);
}
//barre d'action affiché en ecran 1
void BarreEtatDroite() { /*Affiche une barre d'état WIFI et mode action*/
if(OLED_on==false || !OledState) {
return;
}
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.drawLine(110,18,110,64,WHITE); //Ligne séparatrice à droite
//Niveau Wifi
if (WiFi.status() == WL_CONNECTED) {
//Icone niveau connection
int NivSignal = int(WiFi.RSSI()) ;
if (NivSignal<-80) {display.drawBitmap(112, 0, bitmap_Signal1 , 16, 16, WHITE); }
else if(NivSignal<-60) {display.drawBitmap(112, 0, bitmap_Signal2 , 16, 16, WHITE); }
else if(NivSignal<-45) {display.drawBitmap(112, 0, bitmap_Signal3 , 16, 16, WHITE); }
else if(NivSignal<-30) {display.drawBitmap(112, 0, bitmap_Signal4 , 16, 16, WHITE); }
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, WHITE) : display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, WHITE);
}
//Mode en cours du Triac/ssr...
int Mode = 0;
if (MATERIEL_ROUTAGE != -1) Mode = LesActions[MATERIEL_ROUTAGE].TypeEnCours(HeureCouranteDeci, temperature, LTARFbin);
display.setCursor(115,21);
display.setTextColor(SSD1306_WHITE);
if(Mode!=1){
display.print(F("OF"));
}
else {
display.fillRect(114,20,13,10,WHITE);
display.setTextColor(BLACK);
display.print(F("OF"));
}
display.setCursor(115,33);
display.setTextColor(WHITE);
if(Mode!=2){
display.print(F("ON"));
}
else {
display.fillRect(114,32,13,10,WHITE);
display.setTextColor(BLACK);
display.print(F("ON"));
}
display.setCursor(115,45);
display.setTextColor(WHITE);
if(Mode!=3){
display.print(F("PW"));
}
else {
display.fillRect(114,44,13,10,WHITE);
display.setTextColor(BLACK);
display.print(F("PW"));
}
display.setCursor(115,57);
display.setTextColor(WHITE);
if(Mode!=4){
display.print(F("TR"));
}
else {
display.fillRect(114,56,13,10,WHITE);
display.setTextColor(BLACK);
display.print(F("TR"));
}
display.setTextColor(WHITE);
}
//Ecran 2
void Ecran2() {
if(OLED_on==false || !OledState){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(WHITE);
display.println(F("Injectee"));
display.println(F("jour"));
display.print(EnergieJour_M_Injectee);
display.print(F(" Wh"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,55);
display.print(F("V "));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+" h";
display.setCursor(128-(durOn.length()*6),55);
display.print(durOn);
}
//Ecran 3
void Ecran3() {
if(OLED_on==false || !OledState){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(WHITE);
float H = 0;
if(MATERIEL_ROUTAGE != -1 ) H = H_Ouvre[MATERIEL_ROUTAGE];
display.println(F("Heure"));
display.println(F("router"));
display.print(H);
display.println(F("h"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(128-(durOn.length()*6),57);
display.print(durOn);
}
//Affichage du logo
void OledLogo() {
display.clearDisplay();
display.setCursor(0,0);
display.drawBitmap(0, 0, bitmap_Logo , 128, 68, WHITE);
display.setCursor(70,50);
display.print(F("V "));
display.print(Version);
display.display();
}
//Gestion du bouton
void OledBouton() {
//Gestion bouton exctinction
if (button_time > millis()) return;
OledState = !OledState; // inverse l’état de la variable
button_time = millis() + btn_latence;
OledChange=true;
}
Messages : 6
Sujets : 2
Inscription : Jun 2024
Réputation :
0
(08-07-2024, 02:17 PM)Raphael591 a écrit : (07-07-2024, 09:01 PM)Serge 11 a écrit : Super, je vais le tester demain.
Déjà la version 11.11?
Pensez vous pouvoir adapter le code en intégrant un bouton poussoir pour n'allumer l'écran que s'il y a une action sur celui ci?
Merci encore.
Serge
Bonjour,
Fichier avec gestion d'un bouton poussoir pour extinction/allumage de l'écran.
Il suffit de renseigner le pin sur lequel est branché le bouton, voir commentaire.
Je n'ai pas effectué de tests en réel.
Code : /***********************************
AFFICHAGE SUR SSD1306/SH110X
*************************************/
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//Pour écran SH110X
//#include <Adafruit_SH110X.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
// Définir les broches SDA et SCL personalisées
#define SDA_PIN 26
#define SCL_PIN 25
bool OLED_on = false; //Si problème avec l'écran, les procédures sont ignorées
//*******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=false; //Statut oled On/Off (Off par défault)
volatile bool OledChange=false; //Changement sur bouton, true=extinction ecran démarrage
int pinBtnOled = 0; //Indiquer ici le pin du bouton pour gérer l'écran
//******BOUTON OLED ***********/
int MATERIEL_ROUTAGE=-1; //Pour la recherche TRIAC OU RELAIS
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//Pour écran SH110X
//Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const unsigned char bitmap_Sun[] PROGMEM = {
0x00,0x00, // ................
0x20,0x82, // ..#.....#.....#.
0x10,0x84, // ...#....#....#..
0x08,0x08, // ....#.......#...
0x01,0xC0, // .......###......
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x0F,0xF8, // ....#########...
0x6F,0xFB, // .##.#########.##
0x0F,0xF8, // ....#########...
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x11,0xC4, // ...#...###...#..
0x20,0x02, // ..#...........#.
0x40,0x81, // .#......#......#
0x00,0x80 // ........#.......
};
const unsigned char bitmap_Off[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x1F,0xF8, // ...##########...
0x1F,0xF8, // ...##########...
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
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, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x40,0x00, // .#..............
0xC0,0x00, // ##..............
0xC0,0x00 // ##..............
};
const unsigned char bitmap_Signal2[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x04,0x00, // .....#..........
0x0C,0x00, // ....##..........
0x1C,0x00, // ...###..........
0x1C,0x00, // ...###..........
0x5C,0x00, // .#.###..........
0xDC,0x00, // ##.###..........
0xDC,0x00 // ##.###..........
};
const unsigned char bitmap_Signal3[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x40, // .........#......
0x00,0xC0, // ........##......
0x01,0xC0, // .......###......
0x01,0xC0, // .......###......
0x05,0xC0, // .....#.###......
0x0D,0xC0, // ....##.###......
0x1D,0xC0, // ...###.###......
0x1D,0xC0, // ...###.###......
0x5D,0xC0, // .#.###.###......
0xDD,0xC0, // ##.###.###......
0xDD,0xC0 // ##.###.###......
};
const unsigned char bitmap_Signal4[] PROGMEM = {
0x00,0x00, // ................
0x00,0x04, // .............#..
0x00,0x0C, // ............##..
0x00,0x1C, // ...........###..
0x00,0x1C, // ...........###..
0x00,0x5C, // .........#.###..
0x00,0xDC, // ........##.###..
0x01,0xDC, // .......###.###..
0x01,0xDC, // .......###.###..
0x05,0xDC, // .....#.###.###..
0x0D,0xDC, // ....##.###.###..
0x1D,0xDC, // ...###.###.###..
0x1D,0xDC, // ...###.###.###..
0x5D,0xDC, // .#.###.###.###..
0xDD,0xDC, // ##.###.###.###..
0xDD,0xDC // ##.###.###.###..
};
const unsigned char bitmap_Signal0[] PROGMEM = {
0x00,0x00, // ................
0x03,0xE0, // ......#####.....
0x0F,0xF8, // ....#########...
0x1F,0xFC, // ...###########..
0x3E,0x3E, // ..#####...#####.
0x38,0x7E, // ..###....######.
0x70,0xFF, // .###....########
0x71,0xF7, // .###...#####.###
0x73,0xC7, // .###..####...###
0x77,0x87, // .###.####....###
0x3F,0x0E, // ..######....###.
0x3E,0x1E, // ..#####....####.
0x1F,0xFC, // ...###########..
0x0F,0xF8, // ....#########...
0x03,0xE0, // ......#####.....
0x00,0x00 // ................
};
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 // ................................................................................................................................
};
int cligSun = 0;
int BoucleOled = 0;
//Initialisation
void InitSSD(){
//OLED init
Wire.begin(SDA_PIN, SCL_PIN);
pinMode (OLED_RESET, OUTPUT);
//FORCE RESET DE L'ECRAN SI PIN PARTICULIER POUR RESET
if(OLED_RESET != -1) {
digitalWrite(OLED_RESET, HIGH);
digitalWrite(OLED_RESET, LOW);
delay(100);
}
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { //if (!display.begin(SCREEN_ADDRESS, true)) { //Pour SH110X
Serial.println("OLED init failed");
}
else {
//Allumer l'écran.
display.ssd1306_command(SSD1306_DISPLAYON); //Commenter pour SH110X
//oled_command(SH110X_DISPLAYON); //SH110X
OledLogo();
display.setCursor(70,50);
display.print(F("Init..."));
display.display();
OLED_on=true;
}
//Partie gestion bouton
if(pinBtnOled > 0) {
pinMode(pinBtnOled, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pinBtnOled), OledBouton, RISING) ;
}
}
//Procédure boucle des écrans
void OledAffiche(){
if(OLED_on==false) {
return;
}
if (OledChange) {
OledChange=false; //Changement traité
if(OledState) {
//Allumer écran
display.ssd1306_command(SSD1306_DISPLAYON); //Commenter pour SH110X
//oled_command(SH110X_DISPLAYON); //SH110X
BoucleOled=0; //reprise début boucle écran
}
else {
//Eteindre écran
display.ssd1306_command(SSD1306_DISPLAYOFF); //Commenter pour SH110X
//oled_command(SH110X_DISPLAYOFF); //SH110X
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
display.clearDisplay();
BarreEtatDroite();
Ecran1();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 14 ) {
//Ecran 2
display.clearDisplay();
Ecran2();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 18 ) {
//Ecran 3
display.clearDisplay();
Ecran3();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 20 ) {
OledLogo();
BoucleOled++;
}
else {
BoucleOled=0;
}
}
//contenue écran 1
void Ecran1(){
if(OLED_on==false || !OledState) {
return;
}
display.setTextSize(1);
display.setTextColor(WHITE); //display.setTextColor(SH110X_WHITE); //SH110X
//WIFI
display.setCursor(0,5);
if (WiFi.status() == WL_CONNECTED) {
display.print(WiFi.localIP().toString());
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.print(WiFi.softAPIP().toString()) : display.print(F("Pas de wifi !"));
}
//Ligne de séparation
display.drawLine(0,18,128,18,WHITE);
//Puissance sonde maison
display.setCursor(0,24);
display.println(F("Puissance"));
display.setCursor(0,37);
display.setTextSize(2);
display.print(int(PuissanceS_M - PuissanceI_M));
display.setTextSize(1);
//Ouverture du triac/ssr
int Ouv = -1;
if(MATERIEL_ROUTAGE != -1) {
Ouv = 100 - Retard[MATERIEL_ROUTAGE];
}
if(Ouv>0) {
//Icone clignote, signale le routage
if(cligSun==0) {
display.drawBitmap(92, 1, bitmap_Sun , 16, 16, WHITE);
cligSun=1;
}
else {
cligSun=0;
display.drawBitmap(92, 1, bitmap_Off , 16, 16, WHITE);
}
}
else {
//Pas de triac/relais...
}
display.setCursor(0,38);
if(Ouv == -1) {
display.setCursor(82,24);
display.print(F("Ouv")); //Triac erreur
display.drawRect(70, 24, 10, 30, WHITE);
display.setCursor(82,38);
display.print(F(" !"));
}
else {
//Affiche jauge Triac/Relais
display.setCursor(82,24);
display.print(F("Ouv"));
display.drawRect(70, 24, 10, 30, WHITE);
float t = (float(30)/100)*Ouv;
display.fillRect(70+2, 24+(30-int(t)), 10-4 , int(t), WHITE);
display.setTextSize(1);
display.setCursor(83,38);
display.print(Ouv);
display.print(F("%"));
}
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(108-(durOn.length()*6),57);
display.print(durOn);
}
//barre d'action affiché en ecran 1
void BarreEtatDroite() { /*Affiche une barre d'état WIFI et mode action*/
if(OLED_on==false || !OledState) {
return;
}
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.drawLine(110,18,110,64,WHITE); //Ligne séparatrice à droite
//Niveau Wifi
if (WiFi.status() == WL_CONNECTED) {
//Icone niveau connection
int NivSignal = int(WiFi.RSSI()) ;
if (NivSignal<-80) {display.drawBitmap(112, 0, bitmap_Signal1 , 16, 16, WHITE); }
else if(NivSignal<-60) {display.drawBitmap(112, 0, bitmap_Signal2 , 16, 16, WHITE); }
else if(NivSignal<-45) {display.drawBitmap(112, 0, bitmap_Signal3 , 16, 16, WHITE); }
else if(NivSignal<-30) {display.drawBitmap(112, 0, bitmap_Signal4 , 16, 16, WHITE); }
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, WHITE) : display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, WHITE);
}
//Mode en cours du Triac/ssr...
int Mode = 0;
if (MATERIEL_ROUTAGE != -1) Mode = LesActions[MATERIEL_ROUTAGE].TypeEnCours(HeureCouranteDeci, temperature, LTARFbin);
display.setCursor(115,21);
display.setTextColor(SSD1306_WHITE);
if(Mode!=1){
display.print(F("OF"));
}
else {
display.fillRect(114,20,13,10,WHITE);
display.setTextColor(BLACK);
display.print(F("OF"));
}
display.setCursor(115,33);
display.setTextColor(WHITE);
if(Mode!=2){
display.print(F("ON"));
}
else {
display.fillRect(114,32,13,10,WHITE);
display.setTextColor(BLACK);
display.print(F("ON"));
}
display.setCursor(115,45);
display.setTextColor(WHITE);
if(Mode!=3){
display.print(F("PW"));
}
else {
display.fillRect(114,44,13,10,WHITE);
display.setTextColor(BLACK);
display.print(F("PW"));
}
display.setCursor(115,57);
display.setTextColor(WHITE);
if(Mode!=4){
display.print(F("TR"));
}
else {
display.fillRect(114,56,13,10,WHITE);
display.setTextColor(BLACK);
display.print(F("TR"));
}
display.setTextColor(WHITE);
}
//Ecran 2
void Ecran2() {
if(OLED_on==false || !OledState){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(WHITE);
display.println(F("Injectee"));
display.println(F("jour"));
display.print(EnergieJour_M_Injectee);
display.print(F(" Wh"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,55);
display.print(F("V "));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+" h";
display.setCursor(128-(durOn.length()*6),55);
display.print(durOn);
}
//Ecran 3
void Ecran3() {
if(OLED_on==false || !OledState){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(WHITE);
float H = 0;
if(MATERIEL_ROUTAGE != -1 ) H = H_Ouvre[MATERIEL_ROUTAGE];
display.println(F("Heure"));
display.println(F("router"));
display.print(H);
display.println(F("h"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(128-(durOn.length()*6),57);
display.print(durOn);
}
//Affichage du logo
void OledLogo() {
display.clearDisplay();
display.setCursor(0,0);
display.drawBitmap(0, 0, bitmap_Logo , 128, 68, WHITE);
display.setCursor(70,50);
display.print(F("V "));
display.print(Version);
display.display();
}
//Gestion du bouton
void OledBouton() {
//Gestion bouton exctinction
if (button_time > millis()) return;
OledState = !OledState; // inverse l’état de la variable
button_time = millis() + btn_latence;
OledChange=true;
}
Bonjour et merci pour le code.
Je viens de l'installer mais a la compilation j'ai ce message d'erreur:"Compilation error: 'H_Ouvre' was not declared in this scope".
Il ne faut pas le déclarer dans le code de base?
Messages : 10
Sujets : 0
Inscription : Jun 2024
Réputation :
1
(05-07-2024, 08:48 AM)lucky a écrit : Bonjour,
encore une fois merci pour ce super travail
voici adapté a un afficheur SH110X
/***********************************
AFFICHAGE SUR SH110X
*************************************/
#include <Adafruit_GFX.h>
//#include <Adafruit_SSD1306.h>
//Pour écran SH110X
#include <Adafruit_SH110X.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
// Définir les broches SDA et SCL personalisées
#define SDA_PIN 33
#define SCL_PIN 32
bool OLED_on = false; //Si problème avec l'écran, les procédures sont ignorées
int MATERIEL_ROUTAGE=-1; //Pour la recherche TRIAC OU RELAIS
//Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//Pour écran SH110X
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const unsigned char bitmap_Sun[] PROGMEM = {
0x00,0x00, // ................
0x20,0x82, // ..#.....#.....#.
0x10,0x84, // ...#....#....#..
0x08,0x08, // ....#.......#...
0x01,0xC0, // .......###......
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x0F,0xF8, // ....#########...
0x6F,0xFB, // .##.#########.##
0x0F,0xF8, // ....#########...
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x11,0xC4, // ...#...###...#..
0x20,0x02, // ..#...........#.
0x40,0x81, // .#......#......#
0x00,0x80 // ........#.......
};
const unsigned char bitmap_Off[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x1F,0xF8, // ...##########...
0x1F,0xF8, // ...##########...
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
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, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x40,0x00, // .#..............
0xC0,0x00, // ##..............
0xC0,0x00 // ##..............
};
const unsigned char bitmap_Signal2[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x04,0x00, // .....#..........
0x0C,0x00, // ....##..........
0x1C,0x00, // ...###..........
0x1C,0x00, // ...###..........
0x5C,0x00, // .#.###..........
0xDC,0x00, // ##.###..........
0xDC,0x00 // ##.###..........
};
const unsigned char bitmap_Signal3[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x40, // .........#......
0x00,0xC0, // ........##......
0x01,0xC0, // .......###......
0x01,0xC0, // .......###......
0x05,0xC0, // .....#.###......
0x0D,0xC0, // ....##.###......
0x1D,0xC0, // ...###.###......
0x1D,0xC0, // ...###.###......
0x5D,0xC0, // .#.###.###......
0xDD,0xC0, // ##.###.###......
0xDD,0xC0 // ##.###.###......
};
const unsigned char bitmap_Signal4[] PROGMEM = {
0x00,0x00, // ................
0x00,0x04, // .............#..
0x00,0x0C, // ............##..
0x00,0x1C, // ...........###..
0x00,0x1C, // ...........###..
0x00,0x5C, // .........#.###..
0x00,0xDC, // ........##.###..
0x01,0xDC, // .......###.###..
0x01,0xDC, // .......###.###..
0x05,0xDC, // .....#.###.###..
0x0D,0xDC, // ....##.###.###..
0x1D,0xDC, // ...###.###.###..
0x1D,0xDC, // ...###.###.###..
0x5D,0xDC, // .#.###.###.###..
0xDD,0xDC, // ##.###.###.###..
0xDD,0xDC // ##.###.###.###..
};
const unsigned char bitmap_Signal0[] PROGMEM = {
0x00,0x00, // ................
0x03,0xE0, // ......#####.....
0x0F,0xF8, // ....#########...
0x1F,0xFC, // ...###########..
0x3E,0x3E, // ..#####...#####.
0x38,0x7E, // ..###....######.
0x70,0xFF, // .###....########
0x71,0xF7, // .###...#####.###
0x73,0xC7, // .###..####...###
0x77,0x87, // .###.####....###
0x3F,0x0E, // ..######....###.
0x3E,0x1E, // ..#####....####.
0x1F,0xFC, // ...###########..
0x0F,0xF8, // ....#########...
0x03,0xE0, // ......#####.....
0x00,0x00 // ................
};
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 // ................................................................................................................................
};
int cligSun = 0;
int BoucleOled = 0;
void InitSSD(){
//OLED init
Wire.begin(SDA_PIN, SCL_PIN);
pinMode (OLED_RESET, OUTPUT);
//FORCE RESET DE L'ECRAN SI PIN PARTICULIER POUR RESET
if(OLED_RESET != -1) {
digitalWrite(OLED_RESET, HIGH);
digitalWrite(OLED_RESET, LOW);
delay(100);
}
if (!display.begin(SCREEN_ADDRESS, true)){//if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { //if (!display.begin(SCREEN_ADDRESS, true)) { //Pour SH110X
Serial.println("OLED init failed");
}
else {
//Allumer l'écran.
//display.ssd1306_command(SSD1306_DISPLAYON); //Commenter pour SH110X
OledLogo();
display.setCursor(70,50);
display.print(F("Init..."));
display.display();
OLED_on=true;
}
//
}
void OledAffiche(){
if(OLED_on==false) {
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
display.clearDisplay();
BarreEtatDroite();
Ecran1();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 14 ) {
//Ecran 2
display.clearDisplay();
Ecran2();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 18 ) {
//Ecran 3
display.clearDisplay();
Ecran3();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 20 ) {
OledLogo();
BoucleOled++;
}
else {
BoucleOled=0;
}
}
void Ecran1(){
if(OLED_on==false) {
return;
}
display.setTextSize(1);
//display.setTextColor(WHITE);
display.setTextColor(SH110X_WHITE); //SH110X
//WIFI
display.setCursor(0,5);
if (WiFi.status() == WL_CONNECTED) {
display.print(WiFi.localIP().toString());
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.print(WiFi.softAPIP().toString()) : display.print(F("Pas de wifi !"));
}
//Ligne de séparation
display.drawLine(0,18,128,18,SH110X_WHITE);
//Puissance sonde maison
display.setCursor(0,24);
display.println(F("Puissance"));
display.setCursor(0,37);
display.setTextSize(2);
display.print(int(PuissanceS_M - PuissanceI_M));
display.setTextSize(1);
//Ouverture du triac/ssr
int Ouv = -1;
if(MATERIEL_ROUTAGE != -1) {
Ouv = 100 - Retard[MATERIEL_ROUTAGE];
}
if(Ouv>0) {
//Icone clignote, signale le routage
if(cligSun==0) {
display.drawBitmap(92, 1, bitmap_Sun , 16, 16, SH110X_WHITE);
cligSun=1;
}
else {
cligSun=0;
display.drawBitmap(92, 1, bitmap_Off , 16, 16, SH110X_WHITE);
}
}
else {
//Pas de triac/relais...
}
display.setCursor(0,38);
if(Ouv == -1) {
display.setCursor(82,24);
display.print(F("Ouv")); //Triac erreur
display.drawRect(70, 24, 10, 30, SH110X_WHITE);
display.setCursor(82,38);
display.print(F(" !"));
}
else {
//Affiche jauge Triac/Relais
display.setCursor(82,24);
display.print(F("Ouv"));
display.drawRect(70, 24, 10, 30, SH110X_WHITE);
float t = (float(30)/100)*Ouv;
display.fillRect(70+2, 24+(30-int(t)), 10-4 , int(t), SH110X_WHITE);
display.setTextSize(1);
display.setCursor(83,38);
display.print(Ouv);
display.print(F("%"));
}
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(108-(durOn.length()*6),57);
display.print(durOn);
}
void BarreEtatDroite() { /*Affiche une barre d'état WIFI et mode action*/
if(OLED_on==false) {
return;
}
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.drawLine(110,18,110,64,SH110X_WHITE); //Ligne séparatrice à droite
//Niveau Wifi
if (WiFi.status() == WL_CONNECTED) {
//Icone niveau connection
int NivSignal = int(WiFi.RSSI()) ;
if (NivSignal<-80) {display.drawBitmap(112, 0, bitmap_Signal1 , 16, 16, SH110X_WHITE); }
else if(NivSignal<-60) {display.drawBitmap(112, 0, bitmap_Signal2 , 16, 16, SH110X_WHITE); }
else if(NivSignal<-45) {display.drawBitmap(112, 0, bitmap_Signal3 , 16, 16, SH110X_WHITE); }
else if(NivSignal<-30) {display.drawBitmap(112, 0, bitmap_Signal4 , 16, 16, SH110X_WHITE); }
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, SH110X_WHITE) : display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, SH110X_WHITE);
}
//Mode en cours du Triac/ssr...
int Mode = 0;
if (MATERIEL_ROUTAGE != -1) Mode = LesActions[MATERIEL_ROUTAGE].TypeEnCours(HeureCouranteDeci, temperature, LTARFbin);
display.setCursor(115,21);
display.setTextColor(SH110X_WHITE);
if(Mode!=1){
display.print(F("OF"));
}
else {
display.fillRect(114,20,13,10,SH110X_WHITE);
display.setTextColor(SH110X_BLACK);
display.print(F("OF"));
}
display.setCursor(115,33);
display.setTextColor(SH110X_WHITE);
if(Mode!=2){
display.print(F("ON"));
}
else {
display.fillRect(114,32,13,10,SH110X_WHITE);
display.setTextColor(SH110X_BLACK);
display.print(F("ON"));
}
display.setCursor(115,45);
display.setTextColor(SH110X_WHITE);
if(Mode!=3){
display.print(F("PW"));
}
else {
display.fillRect(114,44,13,10,SH110X_WHITE);
display.setTextColor(SH110X_BLACK);
display.print(F("PW"));
}
display.setCursor(115,57);
display.setTextColor(SH110X_WHITE);
if(Mode!=4){
display.print(F("TR"));
}
else {
display.fillRect(114,56,13,10,SH110X_WHITE);
display.setTextColor(SH110X_BLACK);
display.print(F("TR"));
}
display.setTextColor(SH110X_WHITE);
}
void Ecran2() {
if(OLED_on==false){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(SH110X_WHITE);
display.println(F("Injectee"));
display.println(F("jour"));
display.print(EnergieJour_M_Injectee);
display.print(F(" Wh"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,55);
display.print(F("V "));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+" h";
display.setCursor(128-(durOn.length()*6),55);
display.print(durOn);
}
void Ecran3() {
if(OLED_on==false){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(SH110X_WHITE);
float H = 0;
if(MATERIEL_ROUTAGE != -1 ) H = H_Ouvre[MATERIEL_ROUTAGE];
display.println(F("Heure"));
display.println(F("router"));
display.print(H);
display.println(F("h"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(128-(durOn.length()*6),57);
display.print(durOn);
}
void OledLogo() {
display.clearDisplay();
display.setCursor(0,0);
display.drawBitmap(0, 0, bitmap_Logo , 128, 68, SH110X_WHITE);
display.setCursor(70,50);
display.print(F("V "));
display.print(Version);
display.display();
}
il y avait plusieurs ligne a modif de WHITE a SH110X_WHITE
encore merci..... Bonjour
J'aime bien le style d'affichage, quand je téléverse le programme j'ai le message suivant :
Compilation error: 'H_Ouvre' was not declared in this scope
Merci de votre aide
cdt
Messages : 51
Sujets : 2
Inscription : Jun 2024
Réputation :
7
Il faut être en version 11.
Routeur avec Triac, CE 2500w. Shelly pro em50 pour les mesures. Kit PV pnp 2 kW. Home assistant
Messages : 51
Sujets : 2
Inscription : Jun 2024
Réputation :
7
re,
Si vous pouviez éviter de laisser le code dans vos réponses, ça devient difficilement lisible.
J'ai fait une version qui s'adapte à la compilation en fonction de l'écran SSD1306 ou SH1106.
A faire avant compilation :
Commenter/dé-commenter les lignes suivantes en fonction de votre écran.
#define USE_SSD1306 1 //Pour les écrans SSD1306
//#define USE_SH110X 1 //Pour les écrans SH1106
Définir les pin SDA,SCL pour l'écran : SDA_PIN et SCL_PIN ligne 33/34
Si vous voulez gérer un bouton poussoir pour affichage ou non, définir le pin du bouton : pinBtnOled ligne 44
RAPPEL : les lignes à ajouter dans solar_router_V...ino :
- "InitSSD();" après la ligne "Serial.println("Booting");"
- "OledAffiche();" après l'appel "EnergieQuotidienne();"
Code du fichier supplémentaire pour l'écran :
Code : /***********************************
AFFICHAGE SUR SSD1306/SH110X
*************************************/
//Choisir son écran ICI ************************
#define USE_SSD1306 1 //Pour les écrans SSD1306
//#define USE_SH110X 1 //Pour les écrans SH1106
//Le reste du code ne devrait s'adapter à la compilation
//Voir pour modifier les pin (gpio) écran et bouton
//Choix ecran *************************************
#include <Adafruit_GFX.h>
#define OLED_BLACK 0
#define OLED_WHITE 1
#define OLED_INVERSE 2
//Pour SSD1306
#if(USE_SSD1306)
#include <Adafruit_SSD1306.h>
#endif
//Pour écran SH110X
#if(USE_SH110X)
#include <Adafruit_SH110X.h>
#endif
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
// Définir les broches SDA et SCL personalisées pour écran
#define SDA_PIN 26 //26
#define SCL_PIN 25 //25
bool OLED_on = false; //Si problème avec l'écran, les procédures sont ignorées
//*******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 au démarrage
int pinBtnOled = 0; //Indiquer ici le pin du bouton pour gérer l'écran
//******BOUTON OLED ***********/
int MATERIEL_ROUTAGE=-1; //Pour la recherche TRIAC OU RELAIS
#if USE_SSD1306
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#endif
//Pour écran SH110X
#if USE_SH110X
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#endif
const unsigned char bitmap_Sun[] PROGMEM = {
0x00,0x00, // ................
0x20,0x82, // ..#.....#.....#.
0x10,0x84, // ...#....#....#..
0x08,0x08, // ....#.......#...
0x01,0xC0, // .......###......
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x0F,0xF8, // ....#########...
0x6F,0xFB, // .##.#########.##
0x0F,0xF8, // ....#########...
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x11,0xC4, // ...#...###...#..
0x20,0x02, // ..#...........#.
0x40,0x81, // .#......#......#
0x00,0x80 // ........#.......
};
const unsigned char bitmap_Off[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x1F,0xF8, // ...##########...
0x1F,0xF8, // ...##########...
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
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, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x40,0x00, // .#..............
0xC0,0x00, // ##..............
0xC0,0x00 // ##..............
};
const unsigned char bitmap_Signal2[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x04,0x00, // .....#..........
0x0C,0x00, // ....##..........
0x1C,0x00, // ...###..........
0x1C,0x00, // ...###..........
0x5C,0x00, // .#.###..........
0xDC,0x00, // ##.###..........
0xDC,0x00 // ##.###..........
};
const unsigned char bitmap_Signal3[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x40, // .........#......
0x00,0xC0, // ........##......
0x01,0xC0, // .......###......
0x01,0xC0, // .......###......
0x05,0xC0, // .....#.###......
0x0D,0xC0, // ....##.###......
0x1D,0xC0, // ...###.###......
0x1D,0xC0, // ...###.###......
0x5D,0xC0, // .#.###.###......
0xDD,0xC0, // ##.###.###......
0xDD,0xC0 // ##.###.###......
};
const unsigned char bitmap_Signal4[] PROGMEM = {
0x00,0x00, // ................
0x00,0x04, // .............#..
0x00,0x0C, // ............##..
0x00,0x1C, // ...........###..
0x00,0x1C, // ...........###..
0x00,0x5C, // .........#.###..
0x00,0xDC, // ........##.###..
0x01,0xDC, // .......###.###..
0x01,0xDC, // .......###.###..
0x05,0xDC, // .....#.###.###..
0x0D,0xDC, // ....##.###.###..
0x1D,0xDC, // ...###.###.###..
0x1D,0xDC, // ...###.###.###..
0x5D,0xDC, // .#.###.###.###..
0xDD,0xDC, // ##.###.###.###..
0xDD,0xDC // ##.###.###.###..
};
const unsigned char bitmap_Signal0[] PROGMEM = {
0x00,0x00, // ................
0x03,0xE0, // ......#####.....
0x0F,0xF8, // ....#########...
0x1F,0xFC, // ...###########..
0x3E,0x3E, // ..#####...#####.
0x38,0x7E, // ..###....######.
0x70,0xFF, // .###....########
0x71,0xF7, // .###...#####.###
0x73,0xC7, // .###..####...###
0x77,0x87, // .###.####....###
0x3F,0x0E, // ..######....###.
0x3E,0x1E, // ..#####....####.
0x1F,0xFC, // ...###########..
0x0F,0xF8, // ....#########...
0x03,0xE0, // ......#####.....
0x00,0x00 // ................
};
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 // ................................................................................................................................
};
int cligSun = 0;
int BoucleOled = 0;
//Initialisation
void InitSSD(){
//OLED init
Wire.begin(SDA_PIN, SCL_PIN);
//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 USE_SSD1306
delay(250);
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println("OLED SSD1306 init failed");
}
else {
//Allumer l'écran.
display.ssd1306_command(SSD1306_DISPLAYON);
//oled_command(SH110X_DISPLAYON); //SH110X
OledLogo();
display.setCursor(70,50);
display.print(F("Init..."));
display.display();
OLED_on=true;
}
#endif
#if USE_SH110X
delay(250); // wait for the OLED to power up
if (!display.begin(SCREEN_ADDRESS, true)) { //Pour SH110X
Serial.println("OLED SH110X init failed");
}
else {
//Allumer l'écran.
// ?
OledLogo();
display.setCursor(70,50);
display.print(F("Init..."));
display.display();
OLED_on=true;
}
#endif
//Partie gestion bouton
if(pinBtnOled > 0) {
pinMode(pinBtnOled, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pinBtnOled), OledBouton, RISING) ;
}
}
//Procédure boucle des écrans
void OledAffiche(){
if(OLED_on==false) {
return;
}
if (OledChange) {
OledChange=false; //Changement traité
if(OledState) {
//Allumer écran
#if USE_SSD1306
display.ssd1306_command(SSD1306_DISPLAYON);
#endif
#if USE_SH110X
// ?
#endif
BoucleOled=0; //reprise début boucle écran
}
else {
//Eteindre écran
#if USE_SSD1306
display.ssd1306_command(SSD1306_DISPLAYOFF);
#endif
#if USE_SH110X
// ?, pas trouvé la commande pour off
display.clearDisplay();
display.display();
#endif
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
display.clearDisplay();
BarreEtatDroite();
Ecran1();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 14 ) {
//Ecran 2
display.clearDisplay();
Ecran2();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 18 ) {
//Ecran 3
display.clearDisplay();
Ecran3();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 20 ) {
OledLogo();
BoucleOled++;
}
else {
BoucleOled=0;
}
}
//contenue écran 1
void Ecran1(){
if(OLED_on==false || !OledState) {
return;
}
display.setTextSize(1);
display.setTextColor(OLED_WHITE);
//WIFI
display.setCursor(0,5);
if (WiFi.status() == WL_CONNECTED) {
display.print(WiFi.localIP().toString());
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.print(WiFi.softAPIP().toString()) : display.print(F("Pas de wifi !"));
}
//Ligne de séparation
display.drawLine(0,18,128,18,OLED_WHITE);
//Puissance sonde maison
display.setCursor(0,24);
display.println(F("Puissance"));
display.setCursor(0,37);
display.setTextSize(2);
display.print(int(PuissanceS_M - PuissanceI_M));
display.setTextSize(1);
//Ouverture du triac/ssr
int Ouv = -1;
if(MATERIEL_ROUTAGE != -1) {
Ouv = 100 - Retard[MATERIEL_ROUTAGE];
}
if(Ouv>0) {
//Icone clignote, signale le routage
if(cligSun==0) {
display.drawBitmap(92, 1, bitmap_Sun , 16, 16, OLED_WHITE);
cligSun=1;
}
else {
cligSun=0;
display.drawBitmap(92, 1, bitmap_Off , 16, 16, OLED_WHITE);
}
}
else {
//Pas de triac/relais...
}
display.setCursor(0,38);
if(Ouv == -1) {
display.setCursor(82,24);
display.print(F("Ouv")); //Triac erreur
display.drawRect(70, 24, 10, 30, OLED_WHITE);
display.setCursor(82,38);
display.print(F(" !"));
}
else {
//Affiche jauge Triac/Relais
display.setCursor(82,24);
display.print(F("Ouv"));
display.drawRect(70, 24, 10, 30, OLED_WHITE);
float t = (float(30)/100)*Ouv;
display.fillRect(70+2, 24+(30-int(t)), 10-4 , int(t), OLED_WHITE);
display.setTextSize(1);
display.setCursor(83,38);
display.print(Ouv);
display.print(F("%"));
}
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(108-(durOn.length()*6),57);
display.print(durOn);
}
//barre d'action affiché en ecran 1
void BarreEtatDroite() { /*Affiche une barre d'état WIFI et mode action*/
if(OLED_on==false || !OledState) {
return;
}
display.setTextSize(1);
display.setTextColor(OLED_WHITE);
display.drawLine(110,18,110,64,OLED_WHITE); //Ligne séparatrice à droite
//Niveau Wifi
if (WiFi.status() == WL_CONNECTED) {
//Icone niveau connection
int NivSignal = int(WiFi.RSSI()) ;
if (NivSignal<-80) {display.drawBitmap(112, 0, bitmap_Signal1 , 16, 16, OLED_WHITE); }
else if(NivSignal<-60) {display.drawBitmap(112, 0, bitmap_Signal2 , 16, 16, OLED_WHITE); }
else if(NivSignal<-45) {display.drawBitmap(112, 0, bitmap_Signal3 , 16, 16, OLED_WHITE); }
else if(NivSignal<-30) {display.drawBitmap(112, 0, bitmap_Signal4 , 16, 16, OLED_WHITE); }
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, OLED_WHITE) : display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, OLED_WHITE);
}
//Mode en cours du Triac/ssr...
int Mode = 0;
if (MATERIEL_ROUTAGE != -1) Mode = LesActions[MATERIEL_ROUTAGE].TypeEnCours(HeureCouranteDeci, temperature, LTARFbin);
display.setCursor(115,21);
display.setTextColor(OLED_WHITE);
if(Mode!=1){
display.print(F("OF"));
}
else {
display.fillRect(114,20,13,10,OLED_WHITE);
display.setTextColor(OLED_BLACK);
display.print(F("OF"));
}
display.setCursor(115,33);
display.setTextColor(OLED_WHITE);
if(Mode!=2){
display.print(F("ON"));
}
else {
display.fillRect(114,32,13,10,OLED_WHITE);
display.setTextColor(OLED_BLACK);
display.print(F("ON"));
}
display.setCursor(115,45);
display.setTextColor(OLED_WHITE);
if(Mode!=3){
display.print(F("PW"));
}
else {
display.fillRect(114,44,13,10,OLED_WHITE);
display.setTextColor(OLED_BLACK);
display.print(F("PW"));
}
display.setCursor(115,57);
display.setTextColor(OLED_WHITE);
if(Mode!=4){
display.print(F("TR"));
}
else {
display.fillRect(114,56,13,10,OLED_WHITE);
display.setTextColor(OLED_BLACK);
display.print(F("TR"));
}
display.setTextColor(OLED_WHITE);
}
//Ecran 2
void Ecran2() {
if(OLED_on==false || !OledState){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(OLED_WHITE);
display.println(F("Injectee"));
display.println(F("jour"));
display.print(EnergieJour_M_Injectee);
display.print(F(" Wh"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,55);
display.print(F("V "));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+" h";
display.setCursor(128-(durOn.length()*6),55);
display.print(durOn);
}
//Ecran 3
void Ecran3() {
if(OLED_on==false || !OledState){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(OLED_WHITE);
float H = 0;
if(MATERIEL_ROUTAGE != -1 ) H = H_Ouvre[MATERIEL_ROUTAGE];
display.println(F("Heure"));
display.println(F("router"));
display.print(H);
display.println(F("h"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(128-(durOn.length()*6),57);
display.print(durOn);
}
//Affichage du logo
void OledLogo() {
display.clearDisplay();
display.setCursor(0,0);
display.drawBitmap(0, 0, bitmap_Logo , 128, 68, OLED_WHITE);
display.setCursor(70,50);
display.print(F("V "));
display.print(Version);
display.display();
}
//Gestion du bouton
void OledBouton() {
//Gestion bouton exctinction
if (button_time > millis()) return;
OledState = !OledState; // inverse l’état de la variable
button_time = millis() + btn_latence;
OledChange=true;
}
Routeur avec Triac, CE 2500w. Shelly pro em50 pour les mesures. Kit PV pnp 2 kW. Home assistant
Messages : 84
Sujets : 9
Inscription : Jun 2024
Réputation :
3
09-07-2024, 10:51 AM
(09-07-2024, 10:37 AM)Raphael591 a écrit : re,
Si vous pouviez éviter de laisser le code dans vos réponses, ça devient difficilement lisible.
J'ai fait une version qui s'adapte à la compilation en fonction de l'écran SSD1306 ou SH1106.
A faire avant compilation :
Commenter/dé-commenter les lignes suivantes en fonction de votre écran.
#define USE_SSD1306 1 //Pour les écrans SSD1306
//#define USE_SH110X 1 //Pour les écrans SH1106
Définir les pin SDA,SCL pour l'écran : SDA_PIN et SCL_PIN ligne 33/34
Si vous voulez gérer un bouton poussoir pour affichage ou non, définir le pin du bouton : pinBtnOled ligne 44
RAPPEL : les lignes à ajouter dans solar_router_V...ino :
- "InitSSD();" après la ligne "Serial.println("Booting");"
- "OledAffiche();" après l'appel "EnergieQuotidienne();"
Code du fichier supplémentaire pour l'écran :
Code : /***********************************
AFFICHAGE SUR SSD1306/SH110X
*************************************/
//Choisir son écran ICI ************************
#define USE_SSD1306 1 //Pour les écrans SSD1306
//#define USE_SH110X 1 //Pour les écrans SH1106
//Le reste du code ne devrait s'adapter à la compilation
//Voir pour modifier les pin (gpio) écran et bouton
//Choix ecran *************************************
#include <Adafruit_GFX.h>
#define OLED_BLACK 0
#define OLED_WHITE 1
#define OLED_INVERSE 2
//Pour SSD1306
#if(USE_SSD1306)
#include <Adafruit_SSD1306.h>
#endif
//Pour écran SH110X
#if(USE_SH110X)
#include <Adafruit_SH110X.h>
#endif
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
// Définir les broches SDA et SCL personalisées pour écran
#define SDA_PIN 26 //26
#define SCL_PIN 25 //25
bool OLED_on = false; //Si problème avec l'écran, les procédures sont ignorées
//*******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 au démarrage
int pinBtnOled = 0; //Indiquer ici le pin du bouton pour gérer l'écran
//******BOUTON OLED ***********/
int MATERIEL_ROUTAGE=-1; //Pour la recherche TRIAC OU RELAIS
#if USE_SSD1306
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#endif
//Pour écran SH110X
#if USE_SH110X
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#endif
const unsigned char bitmap_Sun[] PROGMEM = {
0x00,0x00, // ................
0x20,0x82, // ..#.....#.....#.
0x10,0x84, // ...#....#....#..
0x08,0x08, // ....#.......#...
0x01,0xC0, // .......###......
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x0F,0xF8, // ....#########...
0x6F,0xFB, // .##.#########.##
0x0F,0xF8, // ....#########...
0x07,0xF0, // .....#######....
0x07,0xF0, // .....#######....
0x11,0xC4, // ...#...###...#..
0x20,0x02, // ..#...........#.
0x40,0x81, // .#......#......#
0x00,0x80 // ........#.......
};
const unsigned char bitmap_Off[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x1F,0xF8, // ...##########...
0x1F,0xF8, // ...##########...
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
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, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x40,0x00, // .#..............
0xC0,0x00, // ##..............
0xC0,0x00 // ##..............
};
const unsigned char bitmap_Signal2[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x04,0x00, // .....#..........
0x0C,0x00, // ....##..........
0x1C,0x00, // ...###..........
0x1C,0x00, // ...###..........
0x5C,0x00, // .#.###..........
0xDC,0x00, // ##.###..........
0xDC,0x00 // ##.###..........
};
const unsigned char bitmap_Signal3[] PROGMEM = {
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x00, // ................
0x00,0x40, // .........#......
0x00,0xC0, // ........##......
0x01,0xC0, // .......###......
0x01,0xC0, // .......###......
0x05,0xC0, // .....#.###......
0x0D,0xC0, // ....##.###......
0x1D,0xC0, // ...###.###......
0x1D,0xC0, // ...###.###......
0x5D,0xC0, // .#.###.###......
0xDD,0xC0, // ##.###.###......
0xDD,0xC0 // ##.###.###......
};
const unsigned char bitmap_Signal4[] PROGMEM = {
0x00,0x00, // ................
0x00,0x04, // .............#..
0x00,0x0C, // ............##..
0x00,0x1C, // ...........###..
0x00,0x1C, // ...........###..
0x00,0x5C, // .........#.###..
0x00,0xDC, // ........##.###..
0x01,0xDC, // .......###.###..
0x01,0xDC, // .......###.###..
0x05,0xDC, // .....#.###.###..
0x0D,0xDC, // ....##.###.###..
0x1D,0xDC, // ...###.###.###..
0x1D,0xDC, // ...###.###.###..
0x5D,0xDC, // .#.###.###.###..
0xDD,0xDC, // ##.###.###.###..
0xDD,0xDC // ##.###.###.###..
};
const unsigned char bitmap_Signal0[] PROGMEM = {
0x00,0x00, // ................
0x03,0xE0, // ......#####.....
0x0F,0xF8, // ....#########...
0x1F,0xFC, // ...###########..
0x3E,0x3E, // ..#####...#####.
0x38,0x7E, // ..###....######.
0x70,0xFF, // .###....########
0x71,0xF7, // .###...#####.###
0x73,0xC7, // .###..####...###
0x77,0x87, // .###.####....###
0x3F,0x0E, // ..######....###.
0x3E,0x1E, // ..#####....####.
0x1F,0xFC, // ...###########..
0x0F,0xF8, // ....#########...
0x03,0xE0, // ......#####.....
0x00,0x00 // ................
};
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 // ................................................................................................................................
};
int cligSun = 0;
int BoucleOled = 0;
//Initialisation
void InitSSD(){
//OLED init
Wire.begin(SDA_PIN, SCL_PIN);
//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 USE_SSD1306
delay(250);
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println("OLED SSD1306 init failed");
}
else {
//Allumer l'écran.
display.ssd1306_command(SSD1306_DISPLAYON);
//oled_command(SH110X_DISPLAYON); //SH110X
OledLogo();
display.setCursor(70,50);
display.print(F("Init..."));
display.display();
OLED_on=true;
}
#endif
#if USE_SH110X
delay(250); // wait for the OLED to power up
if (!display.begin(SCREEN_ADDRESS, true)) { //Pour SH110X
Serial.println("OLED SH110X init failed");
}
else {
//Allumer l'écran.
// ?
OledLogo();
display.setCursor(70,50);
display.print(F("Init..."));
display.display();
OLED_on=true;
}
#endif
//Partie gestion bouton
if(pinBtnOled > 0) {
pinMode(pinBtnOled, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pinBtnOled), OledBouton, RISING) ;
}
}
//Procédure boucle des écrans
void OledAffiche(){
if(OLED_on==false) {
return;
}
if (OledChange) {
OledChange=false; //Changement traité
if(OledState) {
//Allumer écran
#if USE_SSD1306
display.ssd1306_command(SSD1306_DISPLAYON);
#endif
#if USE_SH110X
// ?
#endif
BoucleOled=0; //reprise début boucle écran
}
else {
//Eteindre écran
#if USE_SSD1306
display.ssd1306_command(SSD1306_DISPLAYOFF);
#endif
#if USE_SH110X
// ?, pas trouvé la commande pour off
display.clearDisplay();
display.display();
#endif
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
display.clearDisplay();
BarreEtatDroite();
Ecran1();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 14 ) {
//Ecran 2
display.clearDisplay();
Ecran2();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 18 ) {
//Ecran 3
display.clearDisplay();
Ecran3();
display.display();
BoucleOled++;
}
else if (BoucleOled <= 20 ) {
OledLogo();
BoucleOled++;
}
else {
BoucleOled=0;
}
}
//contenue écran 1
void Ecran1(){
if(OLED_on==false || !OledState) {
return;
}
display.setTextSize(1);
display.setTextColor(OLED_WHITE);
//WIFI
display.setCursor(0,5);
if (WiFi.status() == WL_CONNECTED) {
display.print(WiFi.localIP().toString());
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.print(WiFi.softAPIP().toString()) : display.print(F("Pas de wifi !"));
}
//Ligne de séparation
display.drawLine(0,18,128,18,OLED_WHITE);
//Puissance sonde maison
display.setCursor(0,24);
display.println(F("Puissance"));
display.setCursor(0,37);
display.setTextSize(2);
display.print(int(PuissanceS_M - PuissanceI_M));
display.setTextSize(1);
//Ouverture du triac/ssr
int Ouv = -1;
if(MATERIEL_ROUTAGE != -1) {
Ouv = 100 - Retard[MATERIEL_ROUTAGE];
}
if(Ouv>0) {
//Icone clignote, signale le routage
if(cligSun==0) {
display.drawBitmap(92, 1, bitmap_Sun , 16, 16, OLED_WHITE);
cligSun=1;
}
else {
cligSun=0;
display.drawBitmap(92, 1, bitmap_Off , 16, 16, OLED_WHITE);
}
}
else {
//Pas de triac/relais...
}
display.setCursor(0,38);
if(Ouv == -1) {
display.setCursor(82,24);
display.print(F("Ouv")); //Triac erreur
display.drawRect(70, 24, 10, 30, OLED_WHITE);
display.setCursor(82,38);
display.print(F(" !"));
}
else {
//Affiche jauge Triac/Relais
display.setCursor(82,24);
display.print(F("Ouv"));
display.drawRect(70, 24, 10, 30, OLED_WHITE);
float t = (float(30)/100)*Ouv;
display.fillRect(70+2, 24+(30-int(t)), 10-4 , int(t), OLED_WHITE);
display.setTextSize(1);
display.setCursor(83,38);
display.print(Ouv);
display.print(F("%"));
}
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(108-(durOn.length()*6),57);
display.print(durOn);
}
//barre d'action affiché en ecran 1
void BarreEtatDroite() { /*Affiche une barre d'état WIFI et mode action*/
if(OLED_on==false || !OledState) {
return;
}
display.setTextSize(1);
display.setTextColor(OLED_WHITE);
display.drawLine(110,18,110,64,OLED_WHITE); //Ligne séparatrice à droite
//Niveau Wifi
if (WiFi.status() == WL_CONNECTED) {
//Icone niveau connection
int NivSignal = int(WiFi.RSSI()) ;
if (NivSignal<-80) {display.drawBitmap(112, 0, bitmap_Signal1 , 16, 16, OLED_WHITE); }
else if(NivSignal<-60) {display.drawBitmap(112, 0, bitmap_Signal2 , 16, 16, OLED_WHITE); }
else if(NivSignal<-45) {display.drawBitmap(112, 0, bitmap_Signal3 , 16, 16, OLED_WHITE); }
else if(NivSignal<-30) {display.drawBitmap(112, 0, bitmap_Signal4 , 16, 16, OLED_WHITE); }
}
else {
(WiFi.getMode() == WIFI_STA)==false ? display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, OLED_WHITE) : display.drawBitmap(112, 0, bitmap_Signal0 , 16, 16, OLED_WHITE);
}
//Mode en cours du Triac/ssr...
int Mode = 0;
if (MATERIEL_ROUTAGE != -1) Mode = LesActions[MATERIEL_ROUTAGE].TypeEnCours(HeureCouranteDeci, temperature, LTARFbin);
display.setCursor(115,21);
display.setTextColor(OLED_WHITE);
if(Mode!=1){
display.print(F("OF"));
}
else {
display.fillRect(114,20,13,10,OLED_WHITE);
display.setTextColor(OLED_BLACK);
display.print(F("OF"));
}
display.setCursor(115,33);
display.setTextColor(OLED_WHITE);
if(Mode!=2){
display.print(F("ON"));
}
else {
display.fillRect(114,32,13,10,OLED_WHITE);
display.setTextColor(OLED_BLACK);
display.print(F("ON"));
}
display.setCursor(115,45);
display.setTextColor(OLED_WHITE);
if(Mode!=3){
display.print(F("PW"));
}
else {
display.fillRect(114,44,13,10,OLED_WHITE);
display.setTextColor(OLED_BLACK);
display.print(F("PW"));
}
display.setCursor(115,57);
display.setTextColor(OLED_WHITE);
if(Mode!=4){
display.print(F("TR"));
}
else {
display.fillRect(114,56,13,10,OLED_WHITE);
display.setTextColor(OLED_BLACK);
display.print(F("TR"));
}
display.setTextColor(OLED_WHITE);
}
//Ecran 2
void Ecran2() {
if(OLED_on==false || !OledState){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(OLED_WHITE);
display.println(F("Injectee"));
display.println(F("jour"));
display.print(EnergieJour_M_Injectee);
display.print(F(" Wh"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,55);
display.print(F("V "));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+" h";
display.setCursor(128-(durOn.length()*6),55);
display.print(durOn);
}
//Ecran 3
void Ecran3() {
if(OLED_on==false || !OledState){
return;
}
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(OLED_WHITE);
float H = 0;
if(MATERIEL_ROUTAGE != -1 ) H = H_Ouvre[MATERIEL_ROUTAGE];
display.println(F("Heure"));
display.println(F("router"));
display.print(H);
display.println(F("h"));
display.setTextSize(1);
//Affichage de la version installée
display.setCursor(0,57);
display.print(F("V"));
display.print(Version);
//Affichage durée de fonctionnement ESP32
int T = int(millis() / 1000);
float DureeOn = float(T) / 3600;
String durOn=String(DureeOn)+"h";
display.setCursor(128-(durOn.length()*6),57);
display.print(durOn);
}
//Affichage du logo
void OledLogo() {
display.clearDisplay();
display.setCursor(0,0);
display.drawBitmap(0, 0, bitmap_Logo , 128, 68, OLED_WHITE);
display.setCursor(70,50);
display.print(F("V "));
display.print(Version);
display.display();
}
//Gestion du bouton
void OledBouton() {
//Gestion bouton exctinction
if (button_time > millis()) return;
OledState = !OledState; // inverse l’état de la variable
button_time = millis() + btn_latence;
OledChange=true;
}
Super merci
ESP32Wroom, Triac 40A "BTA40", Source UxIx2, Cumulus 300L 3000W.
Sonde temperature sur radiateur triac mise en route ventilateur a 25°
réactivité 30 seuil -100
14 panneaux de 410wcc en autoconso micro-onduleur APS DS3
200W max d injection sur reseau
Suivi sur Domoticz
|