EspHome et écran 3.5 3.5" TFT SPI 480*320 V2.0

Bonsoir,

j’ai récemment expérimenté l’écran ili9341 avec un ESP32, sans le tactile, tout parfait donc je pars sur un 3.5" reçu aujourd’hui ref [KMRTM35018-SPI].

Difficile de savoir si c’est un xpt2046, un ili9488… mais la connectique est identique à celle du ili9341.

Donc je fais le même branchement que pour le ili9341.
L’écran s’allume, je peux l’éteindre depuis l’interface HA mais je n’arrive pas à y afficher la moindre chose.

display:
  - platform: ili9xxx
    model: ili9488
    cs_pin: GPIO22
    dc_pin: GPIO21
    reset_pin: GPIO17
    #auto_clear_enabled: false
    update_interval: 1s
    id: my_display

    pages:
      - id: page1
        lambda: |-
          it.printf(1, 8, id(my_font2), "Page 1");

      - id: page2
        lambda: |-
          it.printf(1, 8, id(my_font2), "Page 2");


interval:
  - interval: 5s
    then:
      - display.page.show_next: my_display
      - component.update: my_display

Avez-vous déjà utiliser cet écran avec ESPHome ?
Une conf yaml particulière ?

Bonne soirée
Bob


System Information

version core-2023.3.6
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.10.10
os_name Linux
os_version 5.15.84-v8
arch aarch64
timezone Europe/Paris
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 5000
Installed Version 1.31.0
Stage running
Available Repositories 1252
Downloaded Repositories 23
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 9.5
update_channel stable
supervisor_version supervisor-2023.03.3
agent_version 1.4.1
docker_version 20.10.22
disk_total 457.7 GB
disk_used 26.7 GB
healthy true
supported true
board rpi4-64
supervisor_api ok
version_api ok
installed_addons deCONZ (6.18.0), Let’s Encrypt (4.12.8), File editor (5.5.0), Samba share (10.0.0), Network UPS Tools (0.11.1), Spotify Connect (0.12.3), Terminal & SSH (9.6.1), Portainer (2.0.0), InfluxDB (4.6.0), Grafana (8.2.1), Node-RED (14.1.1), ESPHome (2023.3.1), Studio Code Server (5.5.5)
Dashboards
dashboards 2
resources 15
views 13
mode storage
Recorder
oldest_recorder_run 23 mars 2023 à 20:03
current_recorder_run 23 mars 2023 à 21:03
estimated_db_size 243.61 MiB
database_engine sqlite
database_version 3.38.5
Spotify
api_endpoint_reachable ok
___

Bonjour,
Petite précision, dans les logs j’ai un failed que je n’ai pas sur le ili9341.

[12:21:15][C][ili9xxx:047]: ili9xxx
[12:21:15][C][ili9xxx:047]:   Rotations: 0 °
[12:21:15][C][ili9xxx:047]:   Dimensions: 480px x 320px
[12:21:15][C][ili9xxx:056]:   Color mode: 8bit 332 mode
[12:21:15][C][ili9xxx:060]:   18-Bit Mode: YES
[12:21:15][C][ili9xxx:063]:   Reset Pin: GPIO17
[12:21:15][C][ili9xxx:064]:   DC Pin: GPIO21
[12:21:15][C][ili9xxx:068]:   => Failed to init Memory: YES!

En remplaçant sur ma plaque d’essai, l’écran 3.5" par un ili9341 (dans yaml → model: ili9341), ça fonctionne.
Pas assez de RAM sur l’ESP32 ?
Bob

Est-ce qu’une solution a été trouvé pour cet écran ? Je rencontre quelques problèmes similaires avec un écran proche de celui-ci. L’écran s’allume mais rien ne s’affiche.

J’explore aussi toutes les pistes :slight_smile:

Bonjour,
Je flash régulièrement l’ESP32 connecté à cet écran au fil des mises à jour d’ESPHome mais rien de mieux pour l’instant.
Bob

Bonsoir,
Oui j’ai pu faire fonctionner cet écran avec ESPHome, j’ajoute le tactile et je partage très prochainement le matériel utilisé, le branchement et la conf yaml :wink:

Bonne soirée
Bob

1 « J'aime »

Bonjour,
juste pour informer de l’avancée, peu de temps en ce moment.

Le ili9488 fonctionne avec cet ESP32:

Le tactile fonctionne avec mon branchement et code yaml actuel pour l’écran ili9341 mais pas encore pour le ili9488.

A très vite.
Bob

1 « J'aime »

Bonsoir,
J’avance mais j’ai ce message et je ne trouve pas l’option mentionnée :
image

Merci à vous :wink:
Bob

Hello,
Tu vas dans appareils et services / ESPHome. en face de ton appareil tu clique sur configurer et tu valide dans la fenêtre qui s’ouvre.

1 « J'aime »

Super, merci @Krull56,
Je poursuis demain :+1:
Bonne soirée
Bob

Bonsoir,
Si j’ai pu faire fonctionner l’écran ili9488 avec l’ESP32 TTGO T8 V1.1 ESP32 4 Mo PSRAM sans le tactile pour l’instant mais j’ai des pistes, je me suis pour l’instant concentré sur le ili9341.
Le branchement que je propose est identique pour les deux écrans, pour un ESP32 30 pin et le TTGO T8 V1.1 ESP32 4 Mo PSRAM.
Même si mon projet n’est pas terminé, je partage le branchement et le code yaml ESPHOME.
Pas top présentation mais mais voici le branchement, suivre de 1 à 14 vers les GPIO :

Pour un ili9341 avec un ESP32 VROOM-32 30 pin suivre aussi les GPIO.
Dans le principe, 3 pages avec des flèches en bas pour changer de page, style à améliorer :wink:
La page 1 : Actions tactiles pour allumer des lumières et changement de couleur du texte suivant On / Off
ON


OFF

Ecran 2 : Informations températures…

Ecran 3 : Autre mise en page…

Une approche fonctionnelle :wink:

Inspiration :

Pour le code ESPHOME :

esphome:
  name: esp32displaytouch
  friendly_name: Esp32 9341 touch

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "UD6gWnftSqqILNKrKkjhgf4+oyu0epgLWf3c8sw+4KY="

ota:
  password: "8ce94a8e33f9d39fm235k51d3f7278e1"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.28
    gateway: 192.168.1.254
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32Displaytouch"
    password: "HBEUMlpqiHVD"

captive_portal:

psram:
  mode: octal
  speed: 80MHz
  
spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19
    
sensor:
  - platform: homeassistant
    id: current_temperature_salon
    entity_id: sensor.psalon_temperature
  - platform: homeassistant
    id: current_temperature_ext
    entity_id: sensor.temperature_ext
  - platform: homeassistant
    id: current_temperature_chambre
    entity_id: sensor.temperature_23_chambre
  - platform: homeassistant
    id: current_temperature_garage
    entity_id: sensor.temperature_garage
  - platform: homeassistant
    id: target_temperature_sejour
    entity_id: climate.sejour
    attribute: temperature

# Example configuration entry
time:
  - platform: homeassistant
    id: homeassistant_time

text_sensor:
  - platform: homeassistant
    id: current_saint_ave_next_rain
    entity_id: sensor.saint_ave_next_rain
    attribute: 1_hour_forecast
  - platform: homeassistant
    id: preset_mode_sejour
    entity_id: climate.sejour
    attribute: preset_mode
  - platform: homeassistant
    id: presence_bob
    entity_id: device_tracker.iphone_x2a

binary_sensor: 
  - platform: homeassistant
    id: lampe_marine
    entity_id: light.lampe_marine
    internal: true
  - platform: homeassistant
    id: lampe_cuisine
    entity_id: light.cuisine
    internal: true
  - platform: homeassistant
    id: lampe_plante
    entity_id: light.salon_plante_10
    internal: true

  - platform: touchscreen
    id: touch_key0
    x_min: 6
    x_max: 70
    y_min: 6
    y_max: 70
    #on_press:
    #- logger.log: "Key0 was touched"
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key0
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.lampe_marine

  - platform: touchscreen
    id: touch_key3
    x_min: 6
    x_max: 70
    y_min: 82
    y_max: 152

    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key3
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.cuisine

  - platform: touchscreen
    id: touch_key6
    x_min: 6
    x_max: 70
    y_min: 162
    y_max: 232

    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key6
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.salon_plante_10

  - platform: touchscreen
    id: touch_key9
    x_min: 6
    x_max: 70
    y_min: 252
    y_max: 296
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key9
        then: 
        - display.page.show_previous: my_display 

  - platform: touchscreen
    id: touch_key11
    x_min: 185
    x_max: 252
    y_min: 252
    y_max: 296
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key11
        then: 
        - display.page.show_next: my_display  

font:
  - file: "fonts/arial-1.ttf"
    id: my_font
    size: 16
    glyphs: "<>♡ÆØÅæøå!'%(){}+,-_.:;*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdeéfghijklmnopqrstuvwxyzôç"
  
  - file: "fonts/arial-1.ttf"
    id: my_font12
    size: 12
    glyphs: "<>♡ÆØÅæøå!'%(){}+,-_.:;*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdeéfghijklmnopqrstuvwxyzôç"

  - file: "fonts/arial-1.ttf"
    id: my_font20
    size: 20
    glyphs: "<>♡ÆØÅæøå!'%(){}+,-_.:;*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdeéfghijklmnopqrstuvwxyzôç"

  - file: "fonts/arial-1.ttf"
    id: my_font18
    size: 18
    glyphs: "<>♡ÆØÅæøå!'%(){}+,-_.:;*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdeéfghijklmnopqrstuvwxyzôç"

  - file: "fonts/comic-sans-ms.ttf"
    id: my_font2
    size: 18
    glyphs: "<>♡ÆØÅæøå!'%(){}+,-_.:;*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdeéfghijklmnopqrstuvwxyzôç"


# Define a PWM output on the ESP32
output:
  - platform: ledc
    pin: 32
    id: gpio_32_backlight_pwm

# Define a monochromatic, dimmable light for the backlight
light:
  - platform: monochromatic
    output: gpio_32_backlight_pwm
    name: "Display Backlight"
    id: back_light
    restore_mode: ALWAYS_ON

switch:
  - platform: gpio
    name: "LedBleu2"
    pin: 2
    
display:
  - platform: ili9xxx
    #model: ili9488
    model: ili9341
    #cs_pin: GPIO22
    #dc_pin: GPIO21
    #reset_pin: GPIO1
    cs_pin: GPIO15
    dc_pin: GPIO05
    reset_pin: GPIO4
    rotation: 180
    #auto_clear_enabled: false
    update_interval: 1s
    id: my_display

    pages:

      - id: page1
        lambda: |-
          it.rectangle(0,  0, it.get_width(), it.get_height());
          auto red = Color(255, 0, 0);
          auto white = Color(255, 255, 255);
          auto yellow = Color(255, 255, 0);
          it.line( 80,   0,  80, 319);
          it.line(160,   0, 160, 319);
          it.line(  0,  80, 239,  80);
          it.line(  0, 160, 239, 160);
          it.line(  0, 240, 239, 240);

          it.rectangle(4, 4, 72, 72, yellow);

          if (id(lampe_marine).state) {
             it.print(8, 24, id(my_font20), my_green, "Light1");
          } else{
            it.print(8, 24, id(my_font20), my_red, "Light1");
          }

          it.rectangle(4, 84, 72, 72, yellow);

          if (id(lampe_cuisine).state) {
             it.print(8, 110, id(my_font20), my_green, "Light2");
          } else{
            it.print(8, 110, id(my_font20), my_red, "Light2");
          }

          it.rectangle(4, 164, 72, 72, yellow);
          if (id(lampe_plante).state) {
             it.print(8, 186, id(my_font20), my_green, "Light3");
          } else{
            it.print(8, 186, id(my_font20), my_red, "Light3");
          }
          
          it.rectangle(4, 244, 72, 72, white);
          it.print(20, 270, id(my_font20), "<<<");
          it.rectangle(164, 244, 72, 72, white);
          it.print(180, 270, id(my_font20), ">>>");

#if (id(touchid).touched)
#it.print(165, 70, id(my_font20), "Touche :");
#it.print(12, 24, id(my_font20), "Light1");
#it.print(12, 100, id(my_font20), "Light2");

      - id: page2
        lambda: |-
          auto white = Color(255, 255, 255);
          it.rectangle(0,  0, it.get_width(), it.get_height());
          it.print(5, 3, id(my_font18), my_red, TextAlign::LEFT, "By Bob : ");
          it.strftime(118, 9, id(my_font12), "%d-%m-%Y %H:%M:%S", id(homeassistant_time).now());

          it.print(5, 30, id(my_font18), "Temp salon :");
          it.printf(146, 30, id(my_font18), my_yellow, "%.1f °C", id(current_temperature_salon).state);
          it.print(5, 56, id(my_font18), "Temp Ext :");
          it.printf(146, 56, id(my_font18), my_yellow, "%.1f °C", id(current_temperature_ext).state);
          it.print(5, 82, id(my_font18), "Temp chambre :");
          it.printf(146, 82, id(my_font18), my_yellow, "%.1f °C", id(current_temperature_chambre).state);
          it.print(5, 108, id(my_font18), "Temp garage :");
          it.printf(146, 108, id(my_font18), my_yellow, "%.1f °C", id(current_temperature_garage).state);
          it.print(5, 134, id(my_font18), "Consigne :");
          it.printf(146, 134, id(my_font18), my_yellow, "%.1f °C", id(target_temperature_sejour).state);
          it.print(5, 160, id(my_font18), "Preset :");
          it.printf(146, 160, id(my_font18), my_yellow, "%s",  id(preset_mode_sejour).state.c_str());
          it.print(5, 186, id(my_font18), "Présence Bob :");
          it.printf(146, 192, id(my_font12), my_yellow, "%s",  id(presence_bob).state.c_str());
          it.rectangle(4, 246, 70, 70, white);
          it.print(20, 270, id(my_font20), "<<<");
          it.rectangle(165, 246, 70, 70, white);
          it.print(180, 270, id(my_font20), ">>>");

      - id: page3
        lambda: |-
          auto red = Color(255, 0, 0);
          auto green = Color(0, 255, 0);
          auto blue = Color(0, 0, 255);
          auto white = Color(255, 255, 255);
          // Draw a line from [0,0] to [100,50]
          //it.line(0, 0, 100, 50);
          // Draw the outline of a rectangle with the top left at [50,60], a width of 30 and a height of 42
          it.rectangle(0, 0, 119, 109, white);
          it.rectangle(0, 111, 119, 109, red);
          it.rectangle(121, 0, 119, 109, green);
          it.rectangle(121, 111, 119, 109, blue);
          // Draw the same rectangle, but this time filled.
          //it.filled_rectangle(150, 160, 130, 142);

          // Circles! Let's draw one with the center at [25,25] and a radius of 10
          //it.circle(25, 25, 10);
          // ... and the same thing filled again
          //it.filled_circle(25, 25, 10);
          it.print(5, 7, id(my_font18), "Présence :");
          it.printf(5, 37, id(my_font12), my_yellow, "%s",  id(presence_bob).state.c_str());
          it.printf(5, 124, id(my_font18), "Temp salon :");
          it.printf(5, 152, id(my_font18), "%.1f °C", id(current_temperature_salon).state);
          it.printf(126, 7, id(my_font18), "Temp Ext :");
          it.printf(126, 37, id(my_font18), "%.1f °C", id(current_temperature_ext).state);
          it.printf(126, 124, id(my_font18), "Temp garage :");
          it.printf(126, 152, id(my_font18), "%.1f °C", id(current_temperature_garage).state);
          it.rectangle(4, 246, 70, 70, white);
          it.print(20, 270, id(my_font20), "<<<");
          it.rectangle(165, 246, 70, 70, white);
          it.print(180, 270, id(my_font20), ">>>");


#interval:
#  - interval: 5s
#    then:
#      - display.page.show_next: my_display
#      - component.update: my_display

#if (id(touchid).touched)
#it.print(165, 70, id(my_font20), "Touche :");          
#it.filled_circle(id(touchid).x, id(touchid).y, 30, my_red);

touchscreen:
  platform: xpt2046
  ## Do not give this an `id` of `touch` as that appears to clash with something
  ## internal to the touchscreen component.
  id: touchid
  cs_pin: 14
  interrupt_pin: 27
  # ResinChem Tech found using interrupt_pin to be unreliable. While
  # I didn't have these issues, I find it works fine without it.
  #interrupt_pin: 21
  swap_x_y: false
  #calibration_x_min: 319
  #calibration_x_max: 3691
  #calibration_y_min: 3873
  #calibration_y_max: 453
  calibration_x_min: 3860
  calibration_x_max: 280
  calibration_y_min: 340
  calibration_y_max: 3860
  
  threshold: 400
  update_interval: 50ms
  report_interval: 200ms
  on_touch:
    - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
              id(touchid).x,
              id(touchid).y,
              id(touchid).x_raw,
              id(touchid).y_raw
              );


color:
  - id: my_red
    red: 100%
    green: 0%
    blue: 0%

  - id: my_green
    red: 0%
    green: 100%
    blue: 0%

  - id: my_blue
    red: 0%
    green: 0%
    blue: 100%

  - id: my_yellow
    red: 100%
    green: 100%
    blue: 0%

  - id: my_white
    red: 100%
    green: 100%
    blue: 100%

# Example configuration entry
web_server:
  port: 80

Une pensée pour @Krull56, un voisin :slight_smile: Bob

Bonjour,
Suite à ce sujet : Touch response not working - ILI9488 driver based 3.5inch SPI TFT Display interfacing with Wemos Lolin32 (Esp 32 based ) MCU · Issue #1466 · Bodmer/TFT_eSPI · GitHub
J’ai débranché la borne TDO (MISO) (9 sur mon image) de l’écran ili9488 et le tactile fonctionne, je finalise la calibration de l’écran.

Bob

1 « J'aime »

Bonsoir,
Avant de créer un partage pour l’écran ili9488 je partage ce que j’ai pu faire avec le ili9341 et un ESP32 « classique ».
Page 1 : Des infos

Page 2 : Pilotage tactile des lumières

Page 3 : Pilotage du chauffage (j’utilise simple thermostat"

Page 4: Autre présentation à terminer

Les couleurs ne ressortent pas bien mais franchement content d’y être arrivé :wink:
J’ajoute le yaml dans lequel il y a un peu de commentaire, liens utiles.

Une question : y a t-il possibilité de passer un texte en upper case avec ESPHome

Bonne soirée
Bob

esphome:
  name: esp32displaytouch
  friendly_name: Esp32 9341 touch

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "UD6gWnftSqqILNK55555Zz4+oyu0epgLWf3c8sw+4KY="

ota:
  password: "8ce94a8e33f4444432d7351d3f7278e1"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.28
    gateway: 192.168.1.254
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32Displaytouch"
    password: "HBEijkbqiHVD"

captive_portal:

#psram:
#  mode: octal
#  speed: 80MHz
  
spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19
    
sensor:
  - platform: homeassistant
    id: current_temperature_salon
    entity_id: sensor.new_temp_regul_chauffage
  - platform: homeassistant
    id: current_humidite_salon
    entity_id: sensor.psalon_humidite
  - platform: homeassistant
    id: current_temperature_ext
    entity_id: sensor.temperature_ext
  - platform: homeassistant
    id: current_temperature_chambre
    entity_id: sensor.temperature_23_chambre
  - platform: homeassistant
    id: current_temperature_garage
    entity_id: sensor.temperature_garage
  - platform: homeassistant
    id: target_temperature_sejour
    entity_id: climate.sejour
    attribute: temperature

# Example configuration entry 
time:
  - platform: homeassistant
    id: homeassistant_time

text_sensor:  
  - platform: homeassistant
    id: preset_mode_sejour
    entity_id: climate.sejour
    attribute: preset_mode

  - platform: homeassistant
    id: hvac_action_sejour
    entity_id: climate.sejour
    attribute: hvac_action

  - platform: homeassistant
    id: presence_bob
    entity_id: device_tracker.iphone_x2a
  

#Déclarer ici les entitées qui seront utilisées sur conditions dans les pages
binary_sensor: 
  - platform: homeassistant
    id: lampe_marine
    entity_id: light.lampe_marine
    internal: true
  - platform: homeassistant
    id: lampe_cuisine
    entity_id: light.cuisine
    internal: true
  - platform: homeassistant
    id: lampe_plante
    entity_id: light.salon_plante_10
    internal: true
  - platform: homeassistant
    id: light_salon
    entity_id: light.light_salon
    internal: true
  - platform: homeassistant
    id: light_mezzanine
    entity_id: light.light_mezzanine
    internal: true
  - platform: homeassistant
    id: lampe_salon
    entity_id: light.lampe_salon
    internal: true
  - platform: homeassistant
    id: lampe_ampli
    entity_id: light.lampe_ampli
    internal: true    
  - platform: homeassistant
    id: salon_escalier_11
    entity_id: light.salon_escalier_11
    internal: true 
  - platform: homeassistant
    id: ruban_led_color_light_21
    entity_id: light.ruban_led_color_light_21
    internal: true  
  #Cet input_boolean est utilisé pour passer en mode away mon chauffage quand je sors d'une zone de 100km de mon domicile
  - platform: homeassistant
    id: intchauffage
    entity_id: input_boolean.intchauffage
    internal: true   
  - platform: homeassistant
    id: prise_chaudiere
    entity_id: switch.on_off_plug_in_unit_3_chaudiere 
    internal: true 
  - platform: homeassistant
    id: prise_chambre
    entity_id: switch.on_off_plug_in_unit_15
    internal: true 

  - platform: touchscreen
    id: touch_key1
    name: Zone 1
    x_min: 0
    x_max: 79
    y_min: 0
    y_max: 79
    #Pour définir que cette zone est active uniquement sur la page 1
    page_id: page2
    #on_press:
    #- logger.log: "Key0 was touched"
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key1
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.cuisine

  - platform: touchscreen
    id: touch_key2
    name: Zone 2
    x_min: 82
    x_max: 159
    y_min: 0
    y_max: 79
    page_id: page2
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key2
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.light_salon

  - platform: touchscreen
    id: touch_key3
    name: Zone 3
    x_min: 162
    x_max: 239
    y_min: 0
    y_max: 69
    page_id: page2
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key3
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.light_mezzanine

  - platform: touchscreen
    id: touch_key4
    name: Zone 4
    x_min: 0
    x_max: 79
    y_min: 82
    y_max: 159
    page_id: page2
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key4
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.lampe_marine

  - platform: touchscreen
    id: touch_key5
    name: Zone 5
    x_min: 82
    x_max: 159
    y_min: 82
    y_max: 159
    page_id: page2
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key5
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.lampe_salon

  - platform: touchscreen
    id: touch_key6
    name: Zone 6
    x_min: 162
    x_max: 239
    y_min: 82
    y_max: 159
    page_id: page2
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key6
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.lampe_ampli

  - platform: touchscreen
    id: touch_key7
    name: Zone 7
    x_min: 0
    x_max: 79
    y_min: 162
    y_max: 239
    page_id: page2
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key7
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.salon_plante_10

  - platform: touchscreen
    id: touch_key8
    name: Zone 8
    x_min: 82
    x_max: 159
    y_min: 162
    y_max: 239
    page_id: page2
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key8
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.salon_escalier_11

  - platform: touchscreen
    id: touch_key9
    name: Zone 9
    x_min: 162
    x_max: 239
    y_min: 162
    y_max: 239
    page_id: page2
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key9
        then: 
        - homeassistant.service:
            service: light.toggle
            data: 
              entity_id: light.ruban_led_color_light_21

  - platform: touchscreen
    id: touch_key10
    x_min: 0
    x_max: 79
    y_min: 242
    y_max: 319
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key10
        then: 
        - display.page.show_previous: my_display 

  - platform: touchscreen
    id: touch_key11
    x_min: 182
    x_max: 239
    y_min: 242
    y_max: 319
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key11
        then: 
        - display.page.show_next: my_display  

  - platform: touchscreen
    id: touch_key1d
    name: Zone 1d
    x_min: 0
    x_max: 79
    y_min: 0
    y_max: 79
    page_id: page3
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key1d
        then: 
        - homeassistant.service:
            service: climate.set_preset_mode
            data: 
              entity_id: climate.sejour
              preset_mode: away

  - platform: touchscreen
    id: touch_key2d
    name: Zone 2d
    x_min: 82
    x_max: 159
    y_min: 0
    y_max: 79
    page_id: page3
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key2d
        then: 
        - homeassistant.service:
            service: climate.set_preset_mode
            data: 
              entity_id: climate.sejour
              preset_mode: sleep

  - platform: touchscreen
    id: touch_key3d
    name: Zone 3d
    x_min: 162
    x_max: 239
    y_min: 0
    y_max: 69
    page_id: page3
    on_press:
    - logger.log: "Bruno"
    - logger.log:
        format: "Situation chauffage  %s and consigne %.1f"
        args: [ 'id(preset_mode_sejour).state.c_str()', 'id(target_temperature_sejour).state' ]
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key3d
        then: 
        - homeassistant.service:
            service: climate.set_preset_mode
            data: 
              entity_id: climate.sejour
              preset_mode: eco



  - platform: touchscreen
    id: touch_key6d
    name: Zone 6d
    x_min: 162
    x_max: 239
    y_min: 82
    y_max: 159
    page_id: page3
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key6d
        then: 
        - homeassistant.service:
            service: input_boolean.toggle
            data: 
              entity_id: input_boolean.intchauffage

  - platform: touchscreen
    id: touch_key4d
    name: Zone 4d
    x_min: 0
    x_max: 79
    y_min: 82
    y_max: 159
    page_id: page3
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key4d
        then: 
        - homeassistant.service:
            service: climate.set_preset_mode
            data: 
              entity_id: climate.sejour
              preset_mode: home

  - platform: touchscreen
    id: touch_key5d
    name: Zone 5d
    x_min: 82
    x_max: 159
    y_min: 82
    y_max: 159
    page_id: page3
    on_state: 
      if: 
        condition: 
          binary_sensor.is_on: touch_key5d
        then: 
        - homeassistant.service:
            service: climate.set_preset_mode
            data: 
              entity_id: climate.sejour
              preset_mode: comfort

font:
  - file: "fonts/arial-1.ttf"
    id: my_font
    size: 16
    glyphs: "<>♡ÆØÅæøå!'%(){}+,-_.:;*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdeéfghijklmnopqrstuvwxyzôç"
  
  - file: "fonts/arial-1.ttf"
    id: my_font11
    size: 11
    glyphs: "<>♡ÆØÅæøå!'%(){}+,-_.:;*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdeéfghijklmnopqrstuvwxyzôç"

  - file: "fonts/arial-1.ttf"
    id: my_font12
    size: 12
    glyphs: "<>♡ÆØÅæøå!'%(){}+,-_.:;*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdeéfghijklmnopqrstuvwxyzôç"

  - file: "fonts/arial-1.ttf"
    id: my_font20
    size: 20
    glyphs: "<>♡ÆØÅæøå!'%(){}+,-_.:;*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdeéfghijklmnopqrstuvwxyzôç"

  - file: "fonts/arial-1.ttf"
    id: my_font18
    size: 18
    glyphs: "<>♡ÆØÅæøå!'%(){}+,-_.:;*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdeéfghijklmnopqrstuvwxyzôç"

  - file: "fonts/comic-sans-ms.ttf"
    id: my_font2
    size: 18
    glyphs: "<>♡ÆØÅæøå!'%(){}+,-_.:;*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdeéfghijklmnopqrstuvwxyzôç"

  #https://pictogrammers.com/library/mdi/ copier depuis le site
  #https://forum.hacf.fr/t/besoin-daide-avec-les-glyphs-et-les-fonts/26543
  #https://github.com/Templarian/MaterialDesign-Webfont/blob/master/fonts/materialdesignicons-webfont.ttf

  - file: "fonts/materialdesignicons-webfont.ttf"
    id: material30
    size: 58
    glyphs: 
      - "\U000F0769" # mdi:ceiling-light
      - "\U000F17C7" # mdi:ceiling-light-outline
      - "\U000F08DD" # mdi:floor-lamp
      - "\U000F17C8" # mdi:floor-lamp-outline
      - "\U000F06B5" # mdi:mdi:lamp
      - "\U000F17D0" # mdi:mdi:lamp-outline
      - "\U000F0335" # mdi:lightbulb
      - "\U000F0336" # mdi:lightbulb-outline
      - "\U000F0731" # mdi:arrow-left-bold
      - "\U000F0734" # mdi:arrow-right-bold
      - "\U000F1051" # mdi:led-strip-variant
      - "\U000F1A4B" # mdi:led-strip-variant-off
      - "\U000F0521" # mdi:toggle-switch
      - "\U000F0A19" # mdi:toggle-switch-off-outline
      - "\U000F032A" # mdi:leaf
      - "\U000F04B9" # mdi:sofa
      - "\U000F0717" # mdi:snowflake
      - "\U000F0A48" # mdi:exit-run
      - "\U000F0238" # mdi:fire
      - "\U000F0594" # mdi:weather-night
      - "\U000F0827" # mdi:home-heart

  - file: "fonts/materialdesignicons-webfont.ttf"
    id: material28
    size: 28
    glyphs: 
      - "\U000F1A80" # mdi:thermometer-water
      - "\U000F050F" # mdi:thermometer
      - "\U000F058E" # mdi:water-percent


# Define a PWM output on the ESP32
output:
  - platform: ledc
    pin: 32
    id: gpio_32_backlight_pwm

# Define a monochromatic, dimmable light for the backlight
light:
  - platform: monochromatic
    output: gpio_32_backlight_pwm
    name: "Display Backlight"
    id: back_light
    restore_mode: ALWAYS_ON

switch:
  - platform: gpio
    name: "LedBleu2"
    pin: 2
    
display:
  - platform: ili9xxx
    #model: ili9488
    model: ili9341
    cs_pin: GPIO15
    dc_pin: GPIO05
    reset_pin: GPIO4
    rotation: 180
    #auto_clear_enabled: false
    update_interval: 1s
    id: my_display

  #A insérer dans une page pour un quadrillage  
  #it.line( 80,   0,  80, 319);
  #it.line(160,   0, 160, 319);
  #it.line(  0,  80, 239,  80);
  #it.line(  0, 160, 239, 160);
  #it.line(  0, 240, 239, 240);

    pages:

      - id: page1
        lambda: |-
          auto white = Color(255, 255, 255);
          it.rectangle(0,  0, it.get_width(), it.get_height());
          it.print(5, 3, id(my_font18), my_red, TextAlign::LEFT, "By Bob : ");
          it.strftime(118, 9, id(my_font12), "%d-%m-%Y %H:%M:%S", id(homeassistant_time).now());

          it.print(5, 30, id(my_font18), "Temp Salon :");
          it.printf(146, 30, id(my_font18), my_yellow, "%.1f °C", id(current_temperature_salon).state);
          it.print(5, 56, id(my_font18), "Temp Ext :");
          it.printf(146, 56, id(my_font18), my_yellow, "%.1f °C", id(current_temperature_ext).state);
          it.print(5, 82, id(my_font18), "Temp Chambre :");
          it.printf(146, 82, id(my_font18), my_yellow, "%.1f °C", id(current_temperature_chambre).state);
          it.print(5, 108, id(my_font18), "Temp Garage :");
          it.printf(146, 108, id(my_font18), my_yellow, "%.1f °C", id(current_temperature_garage).state);
          it.print(5, 134, id(my_font18), "Consigne T °C:");
          it.printf(146, 134, id(my_font18), my_yellow, "%.1f °C", id(target_temperature_sejour).state);
          it.print(5, 160, id(my_font18), "Humidité :");
          it.printf(146, 160, id(my_font18), my_yellow, "%.0f Pct",  id(current_humidite_salon).state);
          
          it.print(5, 186, id(my_font18), "Prise Gaz. :");
          if (id(prise_chaudiere).state) {
            it.printf(146, 186, id(my_font18), my_orange, "Allumée");
          } else {
            it.printf(146, 186, id(my_font18), my_blue, "Eteinte");
          }

          it.print(5, 212, id(my_font18), "Prise Chamb. :");
          if (id(prise_chambre).state) {
            it.printf(146, 212, id(my_font18), my_orange,"Allumée");
          } else {
            it.printf(146, 212, id(my_font18), my_blue, "Eteinte");
          }

          it.rectangle(4, 246, 70, 70, white);
          it.print(10, 250, id(material30), my_green, "\U000F0731");
          it.print(80,246, id(material28), my_blue, "\U000F050F");
          it.printf(104, 256, id(my_font), my_white, "%.1f °C", id(current_temperature_salon).state);
          it.print(80,282, id(material28), my_blue, "\U000F058E");
          it.printf(104, 290, id(my_font), my_white, "%.0f Pct", id(current_humidite_salon).state);
          it.rectangle(165, 246, 70, 70, white);
          it.print(172, 250, id(material30), my_green, "\U000F0734");

      - id: page2
        lambda: |-
          it.rectangle(0,  0, it.get_width(), it.get_height());
          auto red = Color(255, 0, 0);
          auto white = Color(255, 255, 255);
          auto yellow = Color(255, 255, 0);
          auto blue = Color(0, 0, 255);
          auto green = Color(0, 255, 0);

          it.rectangle(4, 4, 72, 72, yellow);
          it.print(20, 5, id(my_font12), my_white, "Cuisine");
          if (id(lampe_cuisine).state) {
            it.print(10, 14, id(material30), my_orange, "\U000F0769"); 
          } else{
            it.print(10, 14, id(material30), my_blue, "\U000F17C7");
          }
          
          it.rectangle(84, 4, 72, 72, yellow);
          it.print(102, 5, id(my_font12), my_white, "Salon");
          if (id(light_salon).state) {
            it.print(90, 14, id(material30), my_orange, "\U000F0769");
          } else{
            it.print(90, 14, id(material30), my_blue, "\U000F17C7");
          }

          it.rectangle(164, 4, 72, 72, yellow);
          it.print(172, 5, id(my_font12), my_white, "Mezzanine");
          if (id(light_mezzanine).state) {
            it.print(170, 14, id(material30), my_orange, "\U000F0769");
          } else{
            it.print(170, 14, id(material30), my_blue, "\U000F17C7");
          }

          it.rectangle(4, 84, 72, 72, yellow);
          it.print(22, 86, id(my_font12), my_white, "Marine");
          if (id(lampe_marine).state) {
             it.print(10, 94, id(material30), my_orange, "\U000F08DD");
          } else{
             it.print(10, 94, id(material30), my_blue, "\U000F17C8");
          }

          it.rectangle(84, 84, 72, 72, yellow);
          it.print(102, 86, id(my_font12), my_white, "Salon");
          if (id(lampe_salon).state) {
             it.print(90, 94, id(material30), my_orange, "\U000F06B5");
          } else{
             it.print(90, 94, id(material30), my_blue, "\U000F17D0");
          }

          it.rectangle(164, 84, 72, 72, yellow);
          it.print(184, 86, id(my_font12), my_white, "Ampli");
          if (id(lampe_ampli).state) {
             it.print(170, 94, id(material30), my_orange, "\U000F06B5");
          } else{
             it.print(170, 94, id(material30), my_blue, "\U000F17D0");
          }

          it.rectangle(4, 164, 72, 72, yellow);
          it.print(22, 166, id(my_font12), my_white, "Plante");
          if (id(lampe_plante).state) {
             it.print(10, 176, id(material30), my_orange, "\U000F06B5");
          } else{
             it.print(10, 176, id(material30), my_blue, "\U000F17D0");
          }

          it.rectangle(84, 164, 72, 72, yellow);
          it.print(96, 166, id(my_font12), my_white, "Escalier");
          if (id(salon_escalier_11).state) {
            it.print(90, 176, id(material30), my_orange, "\U000F06B5");
          } else{
            it.print(90, 176, id(material30), my_blue, "\U000F17D0");
          }

          it.rectangle(164, 164, 72, 72, yellow);
          it.print(170, 166, id(my_font12), my_white, "Ruban Led");
          if (id(ruban_led_color_light_21).state) {
             it.print(170, 176, id(material30), my_orange, "\U000F1051");
          } else{
             it.print(170, 176, id(material30), my_blue, "\U000F1A4B");
          }
          
          it.rectangle(4, 244, 72, 72, white);
          it.print(10, 250, id(material30), my_green, "\U000F0731");
          it.print(80,246, id(material28), my_blue, "\U000F050F");
          it.printf(104, 256, id(my_font), my_white, "%.1f °C", id(current_temperature_salon).state);
          it.print(80,282, id(material28), my_blue, "\U000F058E");
          it.printf(104, 290, id(my_font), my_white, "%.0f Pct", id(current_humidite_salon).state);
          it.rectangle(164, 244, 72, 72, white);
          it.print(172, 250, id(material30), my_green, "\U000F0734");

#if (id(touchid).touched)
#it.print(165, 70, id(my_font20), "Touche :");

      - id: page3
        lambda: |-
          auto red = Color(255, 0, 0);
          auto green = Color(0, 255, 0);
          auto blue = Color(0, 0, 255);
          auto yellow = Color(255, 255, 0);
          auto white = Color(255, 255, 255);
          it.rectangle(0,  0, it.get_width(), it.get_height());
 
          it.rectangle(4, 4, 72, 72, yellow);
          it.print(26, 5, id(my_font12), my_white, "Away");
          if (id(preset_mode_sejour).state == "away") {
            it.printf(52, 60, id(my_font12), my_white, "%.1f", id(target_temperature_sejour).state);
            it.print(10, 14, id(material30), my_orange, "\U000F0A48"); 
          } else{
            it.print(10, 14, id(material30), my_blue, "\U000F0A48");
          }
          
          it.rectangle(84, 4, 72, 72, yellow);
          it.print(112, 5, id(my_font12), my_white, "Nuit");
          if (id(preset_mode_sejour).state == "sleep") {
            it.printf(128, 60, id(my_font12), my_white, "%.1f", id(target_temperature_sejour).state);
            it.print(90, 14, id(material30), my_orange, "\U000F0594");
          } else{
            it.print(90, 14, id(material30), my_blue, "\U000F0594");
          }

          it.rectangle(164, 4, 72, 72, yellow);
          it.print(190, 5, id(my_font12), my_white, "Eco");
          if (id(preset_mode_sejour).state == "eco") {
            it.print(170, 14, id(material30), my_orange, "\U000F032A");
            it.printf(206, 60, id(my_font12), my_white, "%.1f", id(target_temperature_sejour).state);
          } else{
            it.print(170, 14, id(material30), my_blue, "\U000F032A");
          }

          it.rectangle(4, 84, 72, 72, yellow);
          it.print(18, 86, id(my_font12), my_white, "Présent");
          if (id(preset_mode_sejour).state == "home") {
             it.print(10, 94, id(material30), my_orange, "\U000F0827");
             it.printf(52, 142, id(my_font12), my_white, "%.1f", id(target_temperature_sejour).state);             
          } else{
             it.print(10, 94, id(material30), my_blue, "\U000F0827");
          }

          it.rectangle(84, 84, 72, 72, yellow);
          it.print(96, 86, id(my_font12), my_white, "Confort");
          if (id(preset_mode_sejour).state == "comfort") {
             it.print(90, 94, id(material30), my_orange, "\U000F04B9");
             it.printf(128, 142, id(my_font12), my_white, "%.1f", id(target_temperature_sejour).state);
          } else{
             it.print(90, 94, id(material30), my_blue, "\U000F04B9");
          }

          it.rectangle(164, 84, 72, 72, yellow);
          it.print(174, 86, id(my_font12), my_white, "Int Chauf.");
          if (id(intchauffage).state) {
             it.print(170, 94, id(material30), my_orange, "\U000F0521");
          } else{
             it.print(170, 94, id(material30), my_blue, "\U000F0521");
          }

          it.print(5, 162, id(my_font18), "Mode Chauf. :");
          it.printf(130, 162, id(my_font18), my_yellow, "%s",  id(preset_mode_sejour).state.c_str());

          it.print(5, 184, id(my_font18), "Etat :");
          if (id(hvac_action_sejour).state == "heating") {
            it.printf(130, 184, id(my_font18), my_orange, "En Chauffe");
          } else {
            it.printf(130, 184, id(my_font18), my_blue, "En Pause");
          }

          it.print(5, 206, id(my_font18), "Présence :");
          it.printf(130, 206, id(my_font18), my_yellow, "%s",  id(presence_bob).state.c_str());

          it.rectangle(4, 246, 70, 70, white);
          it.print(10, 250, id(material30), my_green, "\U000F0731");
          it.print(80,246, id(material28), my_blue, "\U000F050F");
          it.printf(104, 256, id(my_font), my_white, "%.1f °C", id(current_temperature_salon).state);
          it.print(80,282, id(material28), my_blue, "\U000F058E");
          it.printf(104, 290, id(my_font), my_white, "%.0f Pct", id(current_humidite_salon).state);
          it.rectangle(165, 246, 70, 70, white);
          it.print(172, 250, id(material30), my_green, "\U000F0734");


      - id: page4
        lambda: |-
          auto red = Color(255, 0, 0);
          auto green = Color(0, 255, 0);
          auto blue = Color(0, 0, 255);
          auto white = Color(255, 255, 255);
          // Draw a line from [0,0] to [100,50]
          //it.line(0, 0, 100, 50);
          // Draw the outline of a rectangle with the top left at [50,60], a width of 30 and a height of 42
          it.rectangle(0, 0, 119, 109, white);
          it.rectangle(0, 111, 119, 109, red);
          it.rectangle(121, 0, 119, 109, green);
          it.rectangle(121, 111, 119, 109, blue);
          // Draw the same rectangle, but this time filled.
          //it.filled_rectangle(150, 160, 130, 142);

          // Circles! Let's draw one with the center at [25,25] and a radius of 10
          //it.circle(25, 25, 10);
          // ... and the same thing filled again
          //it.filled_circle(25, 25, 10);
          it.print(5, 7, id(my_font18), "Présence :");
          it.printf(5, 37, id(my_font12), my_yellow, "%s",  id(presence_bob).state.c_str());
          it.printf(5, 124, id(my_font18), "Temp salon :");
          it.printf(5, 152, id(my_font18), "%.1f °C", id(current_temperature_salon).state);
          it.printf(126, 7, id(my_font18), "Temp Ext :");
          it.printf(126, 37, id(my_font18), "%.1f °C", id(current_temperature_ext).state);
          it.printf(126, 124, id(my_font18), "Temp garage :");
          it.printf(126, 152, id(my_font18), "%.1f °C", id(current_temperature_garage).state);
          it.rectangle(4, 246, 70, 70, white);
          it.print(10, 250, id(material30), my_green, "\U000F0731");
          it.print(80,246, id(material28), my_blue, "\U000F050F");
          it.printf(104, 256, id(my_font), my_white, "%.1f °C", id(current_temperature_salon).state);
          it.print(80,282, id(material28), my_blue, "\U000F058E");
          it.printf(104, 290, id(my_font), my_white, "%.0f Pct", id(current_humidite_salon).state);
          it.rectangle(165, 246, 70, 70, white);
          it.print(172, 250, id(material30), my_green, "\U000F0734");



#interval:
#  - interval: 5s
#    then:
#      - display.page.show_next: my_display
#      - component.update: my_display


touchscreen:
  platform: xpt2046
  ## Do not give this an `id` of `touch` as that appears to clash with something
  ## internal to the touchscreen component.
  id: touchid
  cs_pin: 14
  interrupt_pin: 27
  # ResinChem Tech found using interrupt_pin to be unreliable. While
  # I didn't have these issues, I find it works fine without it.

  swap_x_y: false
  #calibration_x_min: 3860
  #calibration_x_max: 280
  #calibration_y_min: 340
  #calibration_y_max: 3860

  calibration_x_min: 3780
  calibration_x_max: 280
  calibration_y_min: 290
  calibration_y_max: 3870
  
  threshold: 400
  update_interval: 200ms
  report_interval: 500ms
  on_touch:
    - lambda: |-
          ESP_LOGI("calib", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
              id(touchid).x,
              id(touchid).y,
              id(touchid).x_raw,
              id(touchid).y_raw
              );


color:
  - id: my_red
    red: 100%
    green: 0%
    blue: 0%

  - id: my_green
    red: 0%
    green: 100%
    blue: 0%

  - id: my_blue
    red: 0%
    green: 0%
    blue: 100%

  - id: my_yellow
    red: 100%
    green: 100%
    blue: 0%

  - id: my_white
    red: 100%
    green: 100%
    blue: 100%

  - id: my_orange
    hex: FF8100

  - id: my_vert
    hex: C2F907

  - id: my_bleu
    hex: 03a9f4

# Example configuration entry
web_server:
  port: 80   
1 « J'aime »

Bonsoir,

J’ai fait quelque test il faut bien définir toutes les entrées / sorties de ton esp32 et de ton écran.
tu a oublié aussi dans ton code de définir la font que tu utilise
un bout de code pour un esp32 wrom

esphome:
  name: "esp-tft"
  friendly_name: ESP-TFT

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "2ayGVFgyOrP+KqxAuwZZ4ptvlirXwyddrYuDE7FXPpk="

ota:


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-A50664"
    password: "ozLloBGVuydI"

captive_portal:
##############################################################""
sensor:
  - platform: homeassistant
    id: temperature
    entity_id: sensor.thp_bois_temperature
    internal: true

  - platform: homeassistant
    id: temperature_salon
    entity_id: sensor.thp_salon_temperature
    internal: true

text_sensor:
  - platform: homeassistant
    id: saint_jour
    entity_id: sensor.fete_du_jour

time:
  - platform: homeassistant
    id: homeassistant_time
  - platform: sntp
    id: sntp_time
    timezone: Europe/Paris
    servers:
     - 0.pool.ntp.org
     - 1.pool.ntp.org
     - 2.pool.ntp.org   

color:
  - id: mon_rouge
    red: 100%
    green: 3%
    blue: 5%
  - id: mon_bleu
    red: 0%
    green: 0%
    blue: 100%
font:
  - file: "fonts/super_peach.ttf"
    id: font2
    size: 26

  - file: fonts/open-sans-regular.ttf
    id: font1
    size: 20

  - file: fonts/arial_narrow_7.ttf
    id: font3
    size: 24

    glyphs: &font-glyphs
      ['!', '"', '%', '(', ')', '+', '=', ',', '-', '_', '.', ':', '°', ' ','?',
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
      'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
      'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
      'é', 'à', 'è', 'ç', 'ù', 'É', 'À', 'È', 'Ç', 'Ù']

spi:
  clk_pin: 18 # (Pin on display - SCK/T_CLK)
  mosi_pin: 23 # (Pin on display - SDI(MOSI)/T_DIN)
  miso_pin: 12 # (Pin on display - SDO(MISO)/T_DO)


switch:
  - platform: gpio
    pin: 22
    inverted: false
    name: "eclairage-tft"
    id: light_tft
    restore_mode: ALWAYS_ON


display:
  - platform: ili9xxx
    model: ili9341
    rotation: 270
    cs_pin: 5  # Broche CS (Chip Select)
    dc_pin: 2  # Broche DC (Data/Command)
    reset_pin: 0  # Broche de réinitialisation
    dimensions: 240x320
    lambda: |-    
      it.fill(mon_bleu);
      // LIGNE 1
      //it.printf(0, -5, id(font3), "BONJOUR !");
      it.strftime(0, -5, id(font3), "%H:%M:%S", id(sntp_time).now());
      it.printf(80, -5, id(font3) , TextAlign::TOP_LEFT, "%s" , id(saint_jour).state.c_str() );
      // LIGNE 2
      //it.printf(0, 15, id(font3), "LES AMIS");
      it.strftime(0, 15, id(font3), "%H:%M:%S", id(homeassistant_time).now());

      // Print inside temperature (from homeassistant sensor)
      if (id(temperature).has_state()) {
        it.printf(80, 15, id(font3), TextAlign::TOP_LEFT , "%.1f°", id(temperature).state );
      }

      if (id(temperature_salon).has_state()) {
        it.printf(130, 15, id(font3), TextAlign::TOP_LEFT , "%.1f°", id(temperature_salon).state );
      }



      it.printf(0, 35, id(font3), "11:11:11 012345678901234567890-");
      it.printf(0, 55, id(font3), "123456789012345678901234567890-");
      it.printf(0, 75, id(font3), "123456789012345678901234567890-");
      it.printf(0, 95, id(font3), "123456789012345678901234567890-");
      it.printf(0, 115, id(font3), "123456789012345678901234567890-");
      it.printf(0, 135, id(font3), "123456789012345678901234567890-");
      it.printf(0, 155, id(font3), "123456789012345678901234567890-");
      it.printf(0, 175, id(font3), "123456789012345678901234567890-");
      it.printf(0, 195, id(font3), "123456789012345678901234567890-");
      it.printf(0, 215, id(font3), "12345678901234567890123456ABCD-");
      // it.strftime(0, 20, id(open_sans_regular), "%d-%m-%Y %H:%M:%S", id(homeassistant_time).now());

    update_interval: 1s

je pense que tu va devoir modifier la ligne
dimensions: 240x320
par
dimensions: 320x480

la pin RESET de l’écran va sur la borne EN de l’esp

tu doit aussi copier dans un dossier les fichiers .ttf que tu veut utiliser dans le code
ici les voilà
Capture d’écran du 2024-02-06 23-25-01

Si ça peut t’aider !

edit : Je viens de voir que j’avais pas lu tout le fil …
j’ai trouvé pleins de truc je suis pas aussi avancé que toi :wink:

Bonsoir @olive
J’ai defini en effet les polices pour mes symboles et le reste.
Depuis j’ai aussi reçu un i’i9341 plus grand, 2,8 pouce je crois et parfait aussi.
Pour le ili 9488 mon alim est un peu juste et si cela fonctionne il manque un peu de luminosité.
Bob

1 « J'aime »

Merci de ta réponse @Bob
en faite j’ai répondu un peut trop vite sur le 1er post j’ai lu le reste après …
je seche un peut
sur les gpio de la partie toutch screen
j’ai vu dans ton code

touchscreen:
  platform: xpt2046
  ## Do not give this an `id` of `touch` as that appears to clash with something
  ## internal to the touchscreen component.
  id: touchid
  cs_pin: 14
  interrupt_pin: 27
  # ResinChem Tech found using interrupt_pin to be unreliable. While
  # I didn't have these issues, I find it works fine without it.

ou doit t’on déclarer les 3 autres pin dans le code ou alors option pas utilisées ?
10 ?
11 t_cs 14
12 ?
13 ?
14 t_irq 27

merci pour tout ce que tu a déjà poster :wink:

Bonjour @olive
Dans mon post du 23/11 tu as branchement et yaml complet, je pense que tout y est :wink:
Bob

Hello @bob c’est bon j’ai trouvé il y a 3 broches du touch qui sont en commun :wink:

1 « J'aime »

Bon ça va pas trop mal :smile:

ça va remplacer l’ancien (sous arduino méga)