Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5
Code OLED 128*64
#27
(23-06-2024, 04:19 PM)Raphael591 a écrit : Pour ceux que ça intéresse, voici le code de mon affichage sur OLED

[Image: Capture-d-cran-2024-06-23-183753.png] [Image: Capture-d-cran-2024-06-23-183753-2.png] [Image: Capture-d-cran-2024-06-23-183753-3.png]

Nécessite de l'espace programme.
Dans l'IDE, configuration carte, partition : Minimal SPIFFS 1,9MB with OTA


Fichier à ajouter au sketch un fichier OLED.ino
Récupérer les bibliothèques Adafruit depuis l'IDE .
Modifier les PINs utilisés si nécessaire (Ici 26 et 25)
Contenu du fichier :

Code :
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.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;

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// #define SSD1306_RESET 0xE4

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(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println("SSD1306 failed");
    for (;;); // Don't proceed, loop forever
  }
  else {
      //Allumer l'écran.
      display.ssd1306_command(SSD1306_DISPLAYON);
      OledLogo();
      OLED_on=true;
  }
  //
}

void OledAffiche(){
  if (BoucleOled <= 10 ) {
      //Ecran 1
      Ecran1();
      BoucleOled++;
  }
  else if (BoucleOled <= 15 ) {
      //Ecran 2
      Ecran2();
      BoucleOled++;
  }
  else if (BoucleOled <= 16 ) {
      OledLogo();
      BoucleOled++;
  }
  else {
    BoucleOled=0;
  }
}

void Ecran1(){
  if(OLED_on==false) {
    return;
  }
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  //WIFI
  display.setCursor(0,5);
  display.drawLine(91,1,91,15,WHITE);
  if (WiFi.status() == WL_CONNECTED) {
    display.print(WiFi.localIP().toString());
   
    //Niveau connection
    int NivSignal = int(WiFi.RSSI()) ;
    if (NivSignal<-80) {display.drawBitmap(92, 1, bitmap_Signal1 , 16, 16, WHITE); }
    else if(NivSignal<-60) {display.drawBitmap(92, 1, bitmap_Signal2 , 16, 16, WHITE); }
    else if(NivSignal<-45) {display.drawBitmap(92, 1, bitmap_Signal3 , 16, 16, WHITE); }
    else if(NivSignal<-30) {display.drawBitmap(92, 1, bitmap_Signal4 , 16, 16, WHITE); }
  }
  else {
    (WiFi.getMode() == WIFI_STA)==false ? display.print(WiFi.softAPIP().toString()) :  display.print(F("Pas de wifi !")); display.drawBitmap(92, 0, bitmap_Signal0 , 16, 16, WHITE);
  }

 

  //Ligne de séparation
  display.drawLine(0,18,128,18,WHITE);

  //Puissance
  display.setCursor(0,24);
  display.print(F("Puissance "));
  display.print(int(PuissanceS_M - PuissanceI_M));
  display.print(F(" Watt"));
  //Ouverture du triac
  int Ouv = -1;
  for (int i = 0; i < NbActions; i++) {
    if (i == 0) {
       Ouv = 100 - Retard[i];
    }
  }
  display.drawLine(109,1,109,15,WHITE);
  if(Ouv>0) {
    //Icone clignote, signale l'injection
    if(cligSun==0) {
      display.drawBitmap(110, 1, bitmap_Sun , 16, 16, WHITE);
      cligSun=1;
    }
    else {
      cligSun=0;
      display.drawBitmap(110, 1, bitmap_Off , 16, 16, WHITE);
    }
  }
  else {
    display.drawBitmap(110, 1, bitmap_Off , 16, 16, WHITE);
  }
  display.setCursor(0,36);
  if(Ouv == -1) {
    display.print(F("Triac     -")); //Triac erreur
  }
  else {
    //Affiche jauge Triac
    display.setCursor(0,38);
    display.print(F("Triac     "));
    display.drawRect(60, 38, 60, 10, WHITE);
    float t = (float(60)/100)*Ouv;
    display.fillRect(62, 40, int(t), 4, WHITE);
  }
 
  //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);
  display.display();
}

void Ecran2() {
  if(OLED_on==false){
    return;
  }
  display.clearDisplay();
  display.setCursor(0,0);
  display.setTextSize(2);
  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);
  display.display();
}

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();
}




Dans le fichier principal Solar_Router...ino

Dans la boucle setup() {}
Ajouter l'appel InitSSD(); après Serial.println(F("Booting"));

Dans la boule loop() {}
Ajouter l'appel OledAffiche(); après l'appel à la fonction EnergieQuotidienne();


Voila amusez-vous bien !

Bonjour,
J'utilise ce routeur depuis la version 2 et avais au début intégré un écran OLED mais avec les mises a jours, j'ai renoncé à l'utiliser aussi je suis satisfait d'avoir trouvé votre sujet sur le forum.
Je pense l'installer mais je ne trouve pas la ligne de commande "  Serial.println(F("Booting")); " dans l'onglet solar routeur V10.00.ino . Je ne trouve que " Serial.println("Booting");" . Je ne trouve pas la fonction du F.
Vous êtes sur quelle version? Avez vous un numéro de ligne pour m'aider a trouver l'emplacement de la commande?

Autre question. Dans ma version, j'utilise un poussoir sur le GPIO 25 pour allumer l'écran. Il s’éteint ensuite après une tempo. vous pensez que je peux reprendre cette option dans vos lignes de commandes?
D'avance merci.
Cordialement.
Serge 11.
Répondre


Messages dans ce sujet
Code OLED 128*64 - par Raphael591 - 23-06-2024, 04:19 PM
RE: Code OLED 128*64 - par AL53 - 23-06-2024, 07:46 PM
RE: Code OLED 128*64 - par Raphael591 - 23-06-2024, 11:46 PM
RE: Code OLED 128*64 - par AL53 - 24-06-2024, 06:07 PM
RE: Code OLED 128*64 - par DanielJ - 24-06-2024, 04:22 PM
RE: Code OLED 128*64 - par DanielJ - 24-06-2024, 06:32 PM
RE: Code OLED 128*64 - par Raphael591 - 24-06-2024, 08:52 PM
RE: Code OLED 128*64 - par AL53 - 24-06-2024, 10:52 PM
RE: Code OLED 128*64 - par m_fasilleau@yahoo.fr - 24-06-2024, 10:56 PM
RE: Code OLED 128*64 - par Raphael591 - 24-06-2024, 11:03 PM
RE: Code OLED 128*64 - par m_fasilleau@yahoo.fr - 25-06-2024, 08:37 AM
RE: Code OLED 128*64 - par Raphael591 - 25-06-2024, 01:40 PM
RE: Code OLED 128*64 - par m_fasilleau@yahoo.fr - 25-06-2024, 04:11 PM
RE: Code OLED 128*64 - par Psykoz23 - 25-06-2024, 05:17 PM
RE: Code OLED 128*64 - par m_fasilleau@yahoo.fr - 25-06-2024, 07:18 PM
RE: Code OLED 128*64 - par Raphael591 - 25-06-2024, 07:30 PM
RE: Code OLED 128*64 - par Psykoz23 - 25-06-2024, 09:57 PM
RE: Code OLED 128*64 - par Raphael591 - 26-06-2024, 12:39 AM
RE: Code OLED 128*64 - par Psykoz23 - 26-06-2024, 02:00 PM
RE: Code OLED 128*64 - par DanielJ - 26-06-2024, 04:12 PM
RE: Code OLED 128*64 - par F1ATB - 26-06-2024, 04:42 PM
RE: Code OLED 128*64 - par DanielJ - 26-06-2024, 04:53 PM
RE: Code OLED 128*64 - par Raphael591 - 26-06-2024, 05:37 PM
RE: Code OLED 128*64 - par DanielJ - 26-06-2024, 06:33 PM
RE: Code OLED 128*64 - par m_fasilleau@yahoo.fr - 27-06-2024, 08:29 PM
RE: Code OLED 128*64 - par DanielJ - 27-06-2024, 09:05 PM
RE: Code OLED 128*64 - par m_fasilleau@yahoo.fr - 30-06-2024, 09:02 PM
RE: Code OLED 128*64 - par Serge 11 - 28-06-2024, 05:10 PM
RE: Code OLED 128*64 - par DanielJ - 28-06-2024, 05:30 PM
RE: Code OLED 128*64 - par DanielJ - 28-06-2024, 07:41 PM

Atteindre :


Utilisateur(s) parcourant ce sujet : 3 visiteur(s)