IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Arduino Discussion :

TFT tactile SPI et Ethernet Shield 2 SPI en même temps sur un Arduino UNO ?


Sujet :

Arduino

  1. #21
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Bonjour,

    Avant de mettre mes transistors, j'ai vérifier qu'au repos (afficheur TFT inactif, code source qui utilise que l'écran TFT et la dalle tactile) que les niveaux de tension étaient les suivants :
    - CS = +5V
    - CL = 0V
    - MOSI = 0V
    Mon câblage avec des transistors NPN est donc compatible

    Voici le montage :

    Nom : Dsc03609.jpg
Affichages : 757
Taille : 591,8 Ko

    Premiere chose à tester : que ça ne perturbe pas l'afficheur et la dalle tactile.

    Je prends donc le programme qui utilise uniquement l'écran et la dalle tactile pour vérifier, et ça fonctionne

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    // Programme qui fonctionne (écran TFT et dalle tactile) sur Arduino seul
    // Programme qui fonction aussi (écran TFT et dalle tactile) sur Arduino avec Ethernet Shield 2 officiel Arduino
    // L'écran TFT, la dalle tactile et le module Ethernet Shield 2 sont compatibles électriquement
     
    #include "Adafruit_GFX.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques    
    #include "Adafruit_ILI9341.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques
    #include "URTouch.h" // Ajouté au format ZIP         
     
      //On définit les broches pour la partie affichage
      #define TFT_CLK 13
      #define TFT_MISO 12
      #define TFT_MOSI 11
      //#define TFT_CS 10
      #define TFT_CS 0 // On change juste cette broche pour piloter aussi le module Ethernet avec le bus SPI
      #define TFT_DC 9
      #define TFT_RST 8
      Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
      #define TFT_PWM_LED 6 // Un transistor PNP permet de piloter le rétroéclairage 
      // Il est possible d'ajuster le niveau de rétroéclairage en fonction de la luminosité ambiante grâce à une photodiode sur une entrée analogique
      // On peut réduire et éteindre le rétroéclairage après une période d'inactivité de la dalle tactile
      // Et réactiver le rétroéclairage en cas de notification
     
      //On définit les broches pour la partie tactile
      #define t_IRQ 5
      //#define t_MISO 4
      #define t_MISO 7 // La broche 4 est utilisée pour le lecteur SD de l'ethernet Shield
      #define t_MOSI 3
      #define t_CS 2
      #define t_SCK 1
      URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
     
    void setup() {
     
      int radius = 4;
     
      analogWrite(TFT_PWM_LED,128);
     
      tft.begin();
      tft.setRotation(0);
     
      ts.InitTouch(PORTRAIT);
      ts.setPrecision(PREC_EXTREME);
      tft.fillScreen(ILI9341_BLACK);
     
      tft.setTextColor(ILI9341_RED, ILI9341_BLACK);
      tft.setTextSize(2);
     
      tft.fillCircle(10, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(10, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(120, 160, radius, ILI9341_YELLOW);
     
    }
     
    void loop()
    {
      int retro;
      int x, y;
      char Buffer_DispXY[15];
      while (ts.dataAvailable())
      {
        ts.read();
        x = ts.getX();
        y = ts.getY();
     
        if ((x != -1) && (y != -1))
        {
          snprintf_P(Buffer_DispXY, sizeof(Buffer_DispXY), PSTR("X=%3d Y=%3d"), x, y);
          tft.setCursor(55, 5);
          tft.print(Buffer_DispXY);
          retro=y-10;
          if (retro<0) {retro=0;}
          if (retro>255) {retro=255;}
          analogWrite(TFT_PWM_LED,retro);
        }
      }
    }
    Maintenant, le programme qui essayer d'utiliser, en plus le shield Ethernet :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    #include <SPI.h>
    #include <Ethernet.h>
     
    // Ethernet Shield 2 : communicates with both the W5500 and SD card using the SPI bus (through the ICSP header).
    // This is on digital pins 10, 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega.
    // On both boards, pin 10 is used to select the W5500 and pin 4 for the SD card. These pins cannot be used for general I/O.
    // On the Mega, the hardware SS pin, 53, is not used to select either the W5500 or the SD card, but it must be kept as an output or the SPI interface won't work.
     
    #include "Adafruit_GFX.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques    
    #include "Adafruit_ILI9341.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques
    #include "URTouch.h" // Ajouté au format ZIP      
     
      //On définit les broches pour la partie affichage
      #define TFT_CLK 13
      #define TFT_MISO 12
      #define TFT_MOSI 11
      //#define TFT_CS 10
      #define TFT_CS 0 // On change juste cette broche pour piloter aussi le module Ethernet avec le bus SPI
      #define TFT_DC 9
      #define TFT_RST 8
      Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
     
      #define TFT_PWM_LED 6 // Un transistor PNP permet de piloter le rétroéclairage 
      // Il est possible d'ajuster le niveau de rétroéclairage en fonction de la luminosité ambiante grâce à une photodiode sur une entrée analogique
      // On peut réduire et éteindre le rétroéclairage après une période d'inactivité de la dalle tactile
      // Et réactiver le rétroéclairage en cas de notification
     
      //On définit les broches pour la partie tactile
      #define t_IRQ 5
      //#define t_MISO 4
      #define t_MISO 7 // La broche 4 est utilisée pour le lecteur SD de l'ethernet Shield
      #define t_MOSI 3
      #define t_CS 2
      #define t_SCK 1
      URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
     
     
    // Enter a MAC address and IP address for your controller below.
    // The IP address will be dependent on your local network:
    byte mac[] = {
      0xA8, 0x61, 0x0A, 0xAE, 0x75, 0xCA
    };
    IPAddress ip(192, 168, 123, 177);
     
    // Initialize the Ethernet server library
    // with the IP address and port you want to use
    // (port 80 is default for HTTP):
    EthernetServer server(80);
     
        char Buffer_DispXY[15];
        int sensorReading;
        int dernierx;
        int derniery;
     
    void setup() {
      int radius = 4;
      dernierx=-1;
      derniery=-1;
     
      analogWrite(TFT_PWM_LED,128);
     
      tft.begin();
      tft.setRotation(0);
     
      ts.InitTouch(PORTRAIT);
      ts.setPrecision(PREC_EXTREME);
      tft.fillScreen(ILI9341_BLACK);
     
      tft.setTextColor(ILI9341_RED, ILI9341_BLACK);
      tft.setTextSize(2);
     
      tft.fillCircle(10, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(10, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(120, 160, radius, ILI9341_YELLOW);
     
      sensorReading = 555;
      snprintf_P(Buffer_DispXY, sizeof(Buffer_DispXY), PSTR("A = %d"), sensorReading);
      tft.setCursor(55, 5);
      tft.print(Buffer_DispXY);
     
    /*
      // Open serial communications and wait for port to open:
      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
      }
      Serial.println("Ethernet WebServer Example");
    */
     
      // You can use Ethernet.init(pin) to configure the CS pin
      //Ethernet.init(10);  // Most Arduino shields
      //Ethernet.init(5);   // MKR ETH shield
      //Ethernet.init(0);   // Teensy 2.0
      //Ethernet.init(20);  // Teensy++ 2.0
      //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
      //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet
     
      // start the Ethernet connection and the server:
      Ethernet.begin(mac, ip);
     
      // Check for Ethernet hardware present
      if (Ethernet.hardwareStatus() == EthernetNoHardware) {
        //Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
        while (true) {
          delay(1); // do nothing, no point running without Ethernet hardware
        }
      }
      if (Ethernet.linkStatus() == LinkOFF) {
        //Serial.println("Ethernet cable is not connected.");
      }
     
      // start the server
      server.begin();
      //Serial.print("server is at ");
      //Serial.println(Ethernet.localIP());
    }
     
     
    void loop() {
        int retro;
        int x, y;
     
      // listen for incoming clients
      EthernetClient client = server.available();
      if (client) {
        //Serial.println("new client");
        // an http request ends with a blank line
        boolean currentLineIsBlank = true;
        while (client.connected()) {
          if (client.available()) {
            char c = client.read();
            //Serial.write(c);
            // if you've gotten to the end of the line (received a newline
            // character) and the line is blank, the http request has ended,
            // so you can send a reply
            if (c == '\n' && currentLineIsBlank) {
              // send a standard http response header
              client.println(F("HTTP/1.1 200 OK"));
              client.println(F("Content-Type: text/html"));
              client.println(F("Connection: close"));  // the connection will be closed after completion of the response
              client.println(F("Refresh: 5"));  // refresh the page automatically every 5 sec
              client.println();
              client.println(F("<!DOCTYPE HTML>"));
              client.println(F("<html>"));
              // output the value of each analog input pin
              for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
                sensorReading = analogRead(analogChannel);
                client.print(F("analog input "));
                client.print(analogChannel);
                client.print(F(" is "));
                client.print(sensorReading);
                client.println(F("<br />"));
              }
              client.print(F("TFT X="));
              client.print(dernierx);
              client.print(F(" Y="));
              client.print(derniery);
              client.println(F("</html>"));
              break;
            }
            if (c == '\n') {
              // you're starting a new line
              currentLineIsBlank = true;
            } else if (c != '\r') {
              // you've gotten a character on the current line
              currentLineIsBlank = false;
            }
          }
        }
        // give the web browser time to receive the data
        delay(1);
        // close the connection:
        client.stop();
        //Serial.println("client disconnected");
      }
     
        while (ts.dataAvailable())
      {
        ts.read();
        x = ts.getX();
        y = ts.getY();
     
        if ((x != -1) && (y != -1))
        {
          dernierx=x;
          derniery=y;
          snprintf_P(Buffer_DispXY, sizeof(Buffer_DispXY), PSTR("X=%3d Y=%3d"), x, y);
          delay(10);
          tft.setCursor(55, 5);
          tft.print(Buffer_DispXY);
          retro=y-10;
          if (retro<0) {retro=0;}
          if (retro>255) {retro=255;}
          analogWrite(TFT_PWM_LED,retro);
          delay(10);
        }
      }
    }
    Le résultat est le même :
    - l'écran TFT fonctionne au début (setup)
    - le webserveur fonctionne
    - la dalle tactile fonctionne (le site web affiche les dernières coordonnées)
    - mais l'écran TFT ensuite ne fonctionne pas

    J'ai fait différents tests avec différentes vitesses du bus SPI dans w5100.h...

    Avec la vitesse "normale" #define SPI_ETHERNET_SETTINGS SPISettings(14000000, MSBFIRST, SPI_MODE0)
    L'écran TFT reste figé sur ce que je lui avait demandé d'afficher dans le setup

    Avec une vitesse plus faible (je suis descendu jusque #define SPI_ETHERNET_SETTINGS SPISettings(1000, MSBFIRST, SPI_MODE0) pour voir)
    L'écran TFT devient blanc

    Il faut chercher ailleurs...

    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  2. #22
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Citation Envoyé par Vincent PETIT Voir le message
    Salut,
    Tu peux nous donner le lien vers les schémas/docs de chaque element ?
    Le Shield Ethernet 2 est le shield officiel Arduino, pas un clone douteux : https://store.arduino.cc/arduino-ethernet-shield-2

    L'écran TFT est lui une chinoiserie acheté ici : https://www.amazon.fr/gp/product/B07..._title_o00_s03
    Il y a de la doc ici : Http://tftdata.tjc1688.com/2.8_spi/2.8-spi-9341.rar

    Citation Envoyé par Vincent PETIT Voir le message
    Salut,
    Ton oscillo peut décoder le SPI visiblement, est ce que tout est ok de ce côté ?
    Oui j'y ai pensé...
    Le truc c'est que, lorsque je n'utilise pas le shield, l'écran TFT fonctionne
    C'est lorsque j'utilise le shield Ethernet qu'ensuite je n'arrive pas à utiliser l'écran TFT

    Ca va être compliqué, à l'oscilloscope, de séparer les données qui vont au Shield Ethernet et à l'écran TFT
    ... ou alors je retire dans loop tout ce qui concerne le shield Ethernet
    La je pourrais comparer.

    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  3. #23
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Citation Envoyé par f-leb Voir le message
    Bonsoir à tous,

    Le souci peut venir d'une interruption pour prendre la main sur le bus pendant qu'un transfert avec un autre périphérique est en cours.
    C'est pour ça qu'il est recommandé d'encapsuler un transfert au sein d'une transaction SPI, comme le fait la bibliothèque SPI d'Arduino.
    En début de transaction, les paramètres de la communication SPI sont réinitialisés. Et pendant la durée de la transaction, on peut faire en sorte de désactiver les interruptions pour un autre périphérique.

    Si une bibliothèque ne gère pas les transactions, c'est la zoubia...

    Edit : peut-être en passant par une autre bibliothèque pour le TFT. Celle-là comporte un fichier User_Setup.h. En fin de fichier, il y a une ligne // #define SUPPORT_TRANSACTIONS à dé-commenter pour prendre en charge les transactions au cas ou d'autres périphériques utilisent des interruptions.
    Bonjour,

    c'est ce que j'avais suspecté dans le post #6

    Voici un extrait du code de Adafruit_SPITFT.cpp :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    /*!
        @brief  Call before issuing command(s) or data to display. Performs
                chip-select (if required) and starts an SPI transaction (if
                using hardware SPI and transactions are supported). Required
                for all display types; not an SPI-specific function.
    */
    void Adafruit_SPITFT::startWrite(void) {
      SPI_BEGIN_TRANSACTION();
      if (_cs >= 0)
        SPI_CS_LOW();
    }
     
    /*!
        @brief  Call after issuing command(s) or data to display. Performs
                chip-deselect (if required) and ends an SPI transaction (if
                using hardware SPI and transactions are supported). Required
                for all display types; not an SPI-specific function.
    */
    void Adafruit_SPITFT::endWrite(void) {
      if (_cs >= 0)
        SPI_CS_HIGH();
      SPI_END_TRANSACTION();
    }
    Mais effectivement, tester d'autres bibliothèques n'est pas bête... surtout que l'afficheur est très lent avec la lib Adafruit (c'est pénible)

    Celle là a l'air pas mal : https://github.com/marekburiak/ILI9341_due

    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  4. #24
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Bonjour,

    j'ai voulu tester la bibliothèque http://marekburiak.github.io/ILI9341_due/

    je n'arrive même pas à faire un "hello world"

    voici le fichier ILI9341_due_config.h (j'ai d'abord essayé avec le diviseur à 2 puis je l'ai monté...)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    /*
    ILI9341_due_config.h - Arduino Due library for interfacing with ILI9341-based TFTs
     
    Code: https://github.com/marekburiak/ILI9341_due
    Documentation: http://marekburiak.github.io/ILI9341_due/
     
    Copyright (c) 2015  Marek Buriak
     
    */
     
    #ifndef _ILI9341_due_configH_
    #define _ILI9341_due_configH_
     
    // comment out the SPI mode you want to use (does not matter for AVR)
    //#define ILI9341_SPI_MODE_NORMAL	// uses SPI library
    //#define ILI9341_SPI_MODE_EXTENDED	// uses Extended SPI in Due, make sure you use pin 4, 10 or 52 for CS
    #define ILI9341_SPI_MODE_DMA		// uses DMA in Due
     
    // set the clock divider
    #if defined ARDUINO_SAM_DUE
    #define ILI9341_SPI_CLKDIVIDER 128	// for Due
    #elif defined ARDUINO_ARCH_AVR
    #define ILI9341_SPI_CLKDIVIDER SPI_CLOCK_DIV2	// for Uno, Mega,...
    #endif
     
    // uncomment if you want to use SPI transactions. Uncomment it if the library does not work when used with other libraries.
    #define ILI_USE_SPI_TRANSACTION
     
    // comment out if you do need to use scaled text. The text will draw then faster.
    #define TEXT_SCALING_ENABLED
     
    // default letter spacing
    #define DEFAULT_LETTER_SPACING 2
     
    // default line spacing
    #define DEFAULT_LINE_SPACING 0
     
    // sets the space between lines as part of the text
    //#define LINE_SPACING_AS_PART_OF_LETTERS
     
    // number representing the maximum angle (e.g. if 100, then if you pass in start=0 and end=50, you get a half circle)
    // this can be changed with setArcParams function at runtime
    #define DEFAULT_ARC_ANGLE_MAX 360		
     
    // rotational offset in degrees defining position of value 0 (-90 will put it at the top of circle)
    // this can be changed with setAngleOffset function at runtime
    #define DEFAULT_ANGLE_OFFSET -90	
     
     
     
     
    #endif
    Voici le code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    #include <SPI.h>
    #include <ILI9341_due_config.h>
    #include <ILI9341_due.h>
     
    #include "fonts/Arial_bold_14.h"
     
    #define TFT_CS 0
    #define TFT_DC 9
    #define TFT_RST 8
    ILI9341_due tft = ILI9341_due(TFT_CS, TFT_DC, TFT_RST);
     
    #define TFT_PWM_LED 6 // Un transistor PNP permet de piloter le rétroéclairage 
     
    void setup()
    {
    	Serial.begin(9600);
     
    	bool result = tft.begin();
     
    /*
    	Serial.print("TFT begin successful: ");
    	Serial.println(result ? "YES" : "NO");
    */
     
      analogWrite(TFT_PWM_LED,128);
     
    	tft.setRotation(iliRotation270);
    	tft.fillScreen(ILI9341_BLUE);
     
    	tft.setFont(Arial_bold_14);
    	tft.setTextLetterSpacing(5);
    	tft.setTextColor(ILI9341_WHITE, ILI9341_BLUE);
    	tft.printAligned(F("Hello World"), gTextAlignMiddleCenter);
    }
     
    void loop()
    {
     
    	/* add main program code here */
     
    }
    Note : j'ai désactivé les lignes qui utilisaient sérial, mais ça ne change rien

    Lorsque ces lignes étaient activités, le moniteur série m'affichait TFT begin successful: YES

    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  5. #25
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Citation Envoyé par f-leb Voir le message
    Bonsoir à tous,

    Le souci peut venir d'une interruption pour prendre la main sur le bus pendant qu'un transfert avec un autre périphérique est en cours.
    C'est pour ça qu'il est recommandé d'encapsuler un transfert au sein d'une transaction SPI, comme le fait la bibliothèque SPI d'Arduino.
    En début de transaction, les paramètres de la communication SPI sont réinitialisés. Et pendant la durée de la transaction, on peut faire en sorte de désactiver les interruptions pour un autre périphérique.

    Si une bibliothèque ne gère pas les transactions, c'est la zoubia...

    Edit : peut-être en passant par une autre bibliothèque pour le TFT. Celle-là comporte un fichier User_Setup.h. En fin de fichier, il y a une ligne // #define SUPPORT_TRANSACTIONS à dé-commenter pour prendre en charge les transactions au cas ou d'autres périphériques utilisent des interruptions.
    Bonjour,

    je viens de tester la librairie que tu indiques

    voici le fichier User_Setup.h :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    //                            USER DEFINED SETTINGS V16
    //            Set fonts to be loaded, pins used and SPI control method
     
     
    // ##################################################################################
    //
    // Define the fonts that are to be used here
    //
    // ##################################################################################
     
    // Comment out the #defines below with // to stop that font being loaded
    // As supplied font 8 is disabled by commenting out
    //
    // If all fonts are loaded the extra FLASH space required is about 17000 bytes...
    // To save FLASH space only enable the fonts you need!
     
    #define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
    #define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
    //#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
    //#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
    //#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
    //#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
     
     
    // ##################################################################################
    //
    // Define the pins that are used to interface with the display here
    //
    // ##################################################################################
     
    // We must use hardware SPI
    // FYI Mega SCK is pin 52, MOSI is 51, UNO/NanoPro micro etc SCK is pin 13 and MOSI is 11
    // Leonardo Pro micro SCK is pin 15 and MOSI is 16
     
    // These are the control pins I use on my Mega setup
    //   TFT_CS  47  // Chip select control pin
    //   TFT_DC  48  // Data Command control pin
    //   TFT_RST 44  // Reset pin (could connect to Arduino RESET pin)
     
    // These are the control pins I use on my UNO/Nano/Pro Micro/ATmega328 setup
    //   TFT_CS  10  // Chip select control pin
    //   TFT_DC   9  // Data Command control pin
    //   TFT_RST  7  // Reset pin (could connect to Arduino RESET pin)
     
    // ###### EDIT THE PIN NUMBERS IN THE 3 LINES FOLLOWING TO SUIT YOUR SETUP ######
     
    //#define TFT_CS   10  // Chip select control pin
    //#define TFT_DC   8  // Data Command control pin
    //#define TFT_RST  7  // Reset pin (could connect to Arduino RESET pin)
     
    #define TFT_CS   0  // Chip select control pin
    #define TFT_DC   9  // Data Command control pin
    #define TFT_RST  8  // Reset pin (could connect to Arduino RESET pin)
     
     
    // ##################################################################################
    //
    // Other speed up options
    //
    // ##################################################################################
     
    // If your sketch uses the GLCD font in size 1 with background then uncomment
    // this next line will speed up rendering x5, code size will increase 136 bytes
    // Only worth it if you print lots of GLCD font text...
     
    #define FAST_GLCD
     
    // Uncomment the following #define to invoke a 20% faster drawLine() function
    // This speeds up other funtions such as triangle outline drawing too
    // Code size penalty is about 72 bytes
     
    #define FAST_LINE
     
    // Comment out the following #define to stop boundary checking and clipping
    // for fillRectangle()and fastH/V lines. This speeds up other funtions such as text
    // rendering where size>1. Sketch then must not draw graphics/text outside screen
    // boundary. Code saving for no bounds check (i.e. commented out) is 316 bytes
     
    //#define CLIP_CHECK
     
    // Comment out the following #define if "SPI Transactions" do not need to be
    // supported. Tranaction support is required if other SPI devices use interrupts.
    // When commented out the code size will be ~700 bytes smaller and sketches will
    // run slightly faster, so leave it commented out unless you need it!
    // Transaction support is needed to work with SD libraru but not needed with TFT_SdFat
     
    #define SUPPORT_TRANSACTIONS
    Et le code testé :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    // Demo based on:
    // UTFT_Demo_320x240 by Henning Karlsen
    // web: http://www.henningkarlsen.com/electronics
    //
    /*
     
     This sketch uses the GLCD and font 2 only. Disable other fonts to make
     the sketch fit in an UNO!
     
     Make sure all the required fonts are loaded by editting the
     User_Setup.h file in the TFT_ILI9341 library folder.
     
     If using an UNO or Mega (ATmega328 or ATmega2560 processor) then for best
     performance use the F_AS_T option found in the User_Setup.h file in the
     TFT_ILI9341 library folder.
     
     The library uses the hardware SPI pins only:
       For UNO, Nano, Micro Pro ATmega328 based processors
          MOSI = pin 11, SCK = pin 13
       For Mega:
          MOSI = pin 51, SCK = pin 52
     
     The pins used for the TFT chip select (CS) and Data/command (DC) and Reset (RST)
     signal lines to the TFT must also be defined in the library User_Setup.h file.
     
     Sugested TFT connections for UNO and Atmega328 based boards
       sclk 13  // Don't change, this is the hardware SPI SCLK line
       mosi 11  // Don't change, this is the hardware SPI MOSI line
       cs   10  // Chip select for TFT display
       dc   9   // Data/command line
       rst  7   // Reset, you could connect this to the Arduino reset pin
     
     Suggested TFT connections for the MEGA and ATmega2560 based boards
       sclk 52  // Don't change, this is the hardware SPI SCLK line
       mosi 51  // Don't change, this is the hardware SPI MOSI line
       cs   47  // TFT chip select line
       dc   48  // TFT data/command line
       rst  44  // you could alternatively connect this to the Arduino reset
     
      #########################################################################
      ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
      ######       TO SELECT THE FONTS AND PINS YOU USE, SEE ABOVE       ######
      #########################################################################
     */
     
      #define TFT_PWM_LED 6 // Un transistor PNP permet de piloter le rétroéclairage 
      // Il est possible d'ajuster le niveau de rétroéclairage en fonction de la luminosité ambiante grâce à une photodiode sur une entrée analogique
      // On peut réduire et éteindre le rétroéclairage après une période d'inactivité de la dalle tactile
      // Et réactiver le rétroéclairage en cas de notification
     
    #include "SPI.h"
     
    #include "TFT_ILI9341.h"
     
    #define TFT_GREY 0x7BEF
     
    TFT_ILI9341 myGLCD = TFT_ILI9341();       // Invoke custom library
     
    unsigned long runTime = 0;
    void setup()
    {
      randomSeed(analogRead(A0));
      pinMode(7, OUTPUT);
      digitalWrite(7, LOW);
      delay(10);
      digitalWrite(7, HIGH);
     
      analogWrite(TFT_PWM_LED,128);
     
    // Setup the LCD
      myGLCD.init();
      myGLCD.setRotation(1);
    }
     
    void loop()
    {
      randomSeed(millis());
      //randomSeed(1234); // This ensure test is repeatable with exact same draws each loop
      int buf[318];
      int x, x2;
      int y, y2;
      int r;
      runTime = millis();
    // Clear the screen and draw the frame
      myGLCD.fillScreen(TFT_BLACK);
     
     
      myGLCD.fillRect(0, 0, 319, 14,TFT_RED);
     
      myGLCD.fillRect(0, 226, 319, 14,TFT_GREY);
     
      myGLCD.setTextColor(TFT_BLACK,TFT_RED);
      myGLCD.drawCentreString("* TFT_ILI9341 *", 160, 4, 1);
      myGLCD.setTextColor(TFT_YELLOW,TFT_GREY);
      myGLCD.drawCentreString("Adapted by Bodmer", 160, 228,1);
     
      myGLCD.drawRect(0, 14, 319, 211, TFT_BLUE);
     
    // Draw crosshairs
      myGLCD.drawLine(159, 15, 159, 224,TFT_BLUE);
      myGLCD.drawLine(1, 119, 318, 119,TFT_BLUE);
      for (int i=9; i<310; i+=10)
        myGLCD.drawLine(i, 117, i, 121,TFT_BLUE);
      for (int i=19; i<220; i+=10)
        myGLCD.drawLine(157, i, 161, i,TFT_BLUE);
     
    // Draw sin-, cos- and tan-lines  
      myGLCD.setTextColor(TFT_CYAN);
      myGLCD.drawString("Sin", 5, 15,2);
      for (int i=1; i<318; i++)
      {
        myGLCD.drawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95),TFT_CYAN);
      }
      myGLCD.setTextColor(TFT_RED);
      myGLCD.drawString("Cos", 5, 30,2);
      for (int i=1; i<318; i++)
      {
        myGLCD.drawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95),TFT_RED);
      }
      myGLCD.setTextColor(TFT_YELLOW);
      myGLCD.drawString("Tan", 5, 45,2);
      for (int i=1; i<318; i++)
      {
        myGLCD.drawPixel(i,119+(tan(((i*1.13)*3.14)/180)),TFT_YELLOW);
      }
     
      //delay(2000);
     
      myGLCD.fillRect(1,15,317,209,TFT_BLACK);
     
      myGLCD.drawLine(159, 15, 159, 224,TFT_BLUE);
      myGLCD.drawLine(1, 119, 318, 119,TFT_BLUE);
    int col = 0;
    // Draw a moving sinewave
      x=1;
      for (int i=1; i<(317*20); i++) 
      {
        x++;
        if (x==318)
          x=1;
        if (i>318)
        {
          if ((x==159)||(buf[x-1]==119))
            col = TFT_BLUE;
          else
          myGLCD.drawPixel(x,buf[x-1],TFT_BLACK);
        }
        y=119+(sin(((i*1.1)*3.14)/180)*(90-(i / 100)));
        myGLCD.drawPixel(x,y,TFT_BLUE);
        buf[x-1]=y;
      }
     
      //delay(2000);
     
      myGLCD.fillRect(1,15,317,209,TFT_BLACK);
     
    // Draw some filled rectangles
      for (int i=1; i<6; i++)
      {
        switch (i)
        {
          case 1:
            col = TFT_MAGENTA;
            break;
          case 2:
            col = TFT_RED;
            break;
          case 3:
            col = TFT_GREEN;
            break;
          case 4:
            col = TFT_BLUE;
            break;
          case 5:
            col = TFT_YELLOW;
            break;
        }
        myGLCD.fillRect(70+(i*20), 30+(i*20), 60, 60,col);
      }
     
      //delay(2000);
     
      myGLCD.fillRect(1,15,317,209,TFT_BLACK);
     
    // Draw some filled, rounded rectangles
      for (int i=1; i<6; i++)
      {
        switch (i)
        {
          case 1:
            col = TFT_MAGENTA;
            break;
          case 2:
            col = TFT_RED;
            break;
          case 3:
            col = TFT_GREEN;
            break;
          case 4:
            col = TFT_BLUE;
            break;
          case 5:
            col = TFT_YELLOW;
            break;
        }
        myGLCD.fillRoundRect(190-(i*20), 30+(i*20), 60,60, 3,col);
      }
     
      //delay(2000);
     
      myGLCD.fillRect(1,15,317,209,TFT_BLACK);
     
    // Draw some filled circles
      for (int i=1; i<6; i++)
      {
        switch (i)
        {
          case 1:
            col = TFT_MAGENTA;
            break;
          case 2:
            col = TFT_RED;
            break;
          case 3:
            col = TFT_GREEN;
            break;
          case 4:
            col = TFT_BLUE;
            break;
          case 5:
            col = TFT_YELLOW;
            break;
        }
        myGLCD.fillCircle(100+(i*20),60+(i*20), 30,col);
      }
     
      //delay(2000);
     
      myGLCD.fillRect(1,15,317,209,TFT_BLACK);
     
    // Draw some lines in a pattern
     
      for (int i=15; i<224; i+=5)
      {
        myGLCD.drawLine(1, i, (i*1.44)-10, 223,TFT_RED);
      }
     
      for (int i=223; i>15; i-=5)
      {
        myGLCD.drawLine(317, i, (i*1.44)-11, 15,TFT_RED);
      }
     
      for (int i=223; i>15; i-=5)
      {
        myGLCD.drawLine(1, i, 331-(i*1.44), 15,TFT_CYAN);
      }
     
      for (int i=15; i<224; i+=5)
      {
        myGLCD.drawLine(317, i, 330-(i*1.44), 223,TFT_CYAN);
      }
     
      //delay(2000);
     
     
      myGLCD.fillRect(1,15,317,209,TFT_BLACK);
     
    // Draw some random circles
      for (int i=0; i<100; i++)
      {
        x=32+random(256);
        y=45+random(146);
        r=random(30);
        myGLCD.drawCircle(x, y, r,random(0xFFFF));
      }
     
      //delay(2000);
     
      myGLCD.fillRect(1,15,317,209,TFT_BLACK);
     
    // Draw some random rectangles
      for (int i=0; i<100; i++)
      {
        x=2+random(316);
        y=16+random(207);
        x2=2+random(316);
        y2=16+random(207);
        if (x2<x) {
          r=x;x=x2;x2=r;
        }
        if (y2<y) {
          r=y;y=y2;y2=r;
        }
        myGLCD.drawRect(x, y, x2-x, y2-y,random(0xFFFF));
      }
     
      //delay(2000);
     
     
      myGLCD.fillRect(1,15,317,209,TFT_BLACK);
     
    // Draw some random rounded rectangles
      for (int i=0; i<100; i++)
      {
        x=2+random(316);
        y=16+random(207);
        x2=2+random(316);
        y2=16+random(207);
        // We need to get the width and height and do some window checking
        if (x2<x) {
          r=x;x=x2;x2=r;
        }
        if (y2<y) {
          r=y;y=y2;y2=r;
        }
        // We need a minimum size of 6
        if((x2-x)<6) x2=x+6;
        if((y2-y)<6) y2=y+6;
        myGLCD.drawRoundRect(x, y, x2-x,y2-y, 3,random(0xFFFF));
      }
     
      //delay(2000);
     
      myGLCD.fillRect(1,15,317,209,TFT_BLACK);
     
     //randomSeed(1234);
     int colour = 0;
     for (int i=0; i<100; i++)
      {
        x=2+random(316);
        y=16+random(209);
        x2=2+random(316);
        y2=16+random(209);
        colour=random(0xFFFF);
        myGLCD.drawLine(x, y, x2, y2,colour);
      }
     
      //delay(2000);
     
      myGLCD.fillRect(1,15,317,209,TFT_BLACK);
     
      // This test has been modified as it takes more time to calculate the random numbers
      // than to draw the pixels (3 seconds to produce 30,000 randoms)!
      //for (int i=0; i<10000; i++)
      //{
      //  myGLCD.drawPixel(2+random(316), 16+random(209),random(0xFFFF));
      //}
     
      // Draw 10,000 pixels to fill a 100x100 pixel box
      // use the coords as the colour to produce the banding
      byte i = 100;
      while (i--) {
        byte j = 100;
        while (j--) myGLCD.drawPixel(i+110,j+70,i+j);
        //while (j--) myGLCD.drawPixel(i+110,j+70,0xFFFF);
      }
      //delay(2000);
     
      myGLCD.fillScreen(TFT_BLUE);
      myGLCD.fillRoundRect(80, 70, 239-80,169-70, 3,TFT_RED);
     
      myGLCD.setTextColor(TFT_WHITE,TFT_RED);
      myGLCD.drawCentreString("That's it!", 160, 93,2);
      myGLCD.drawCentreString("Restarting in a", 160, 119,2);
      myGLCD.drawCentreString("few seconds...", 160, 132,2);
     
      runTime = millis()-runTime;
      myGLCD.setTextColor(TFT_GREEN,TFT_BLUE);
      myGLCD.drawCentreString("Runtime: (msecs)", 160, 210,2);
      myGLCD.drawNumber(runTime, 130, 225,2);
      delay (5000);
    }
    Pareil, aucun affichage

    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  6. #26
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Bonjour,

    en regardant le code de Adafruit_ILI9341.cpp je remarque ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    /**************************************************************************/
    /*!
        @brief  Instantiate Adafruit ILI9341 driver with software SPI
        @param    cs    Chip select pin #
        @param    dc    Data/Command pin #
        @param    mosi  SPI MOSI pin #
        @param    sclk  SPI Clock pin #
        @param    rst   Reset pin # (optional, pass -1 if unused)
        @param    miso  SPI MISO pin # (optional, pass -1 if unused)
    */
    /**************************************************************************/
    Adafruit_ILI9341::Adafruit_ILI9341(int8_t cs, int8_t dc, int8_t mosi,
                                       int8_t sclk, int8_t rst, int8_t miso)
        : Adafruit_SPITFT(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT, cs, dc, mosi, sclk,
                          rst, miso) {}
     
    /**************************************************************************/
    /*!
        @brief  Instantiate Adafruit ILI9341 driver with hardware SPI using the
                default SPI peripheral.
        @param  cs   Chip select pin # (OK to pass -1 if CS tied to GND).
        @param  dc   Data/Command pin # (required).
        @param  rst  Reset pin # (optional, pass -1 if unused).
    */
    /**************************************************************************/
    Adafruit_ILI9341::Adafruit_ILI9341(int8_t cs, int8_t dc, int8_t rst)
        : Adafruit_SPITFT(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT, cs, dc, rst) {}
    Dans mon code et mon montage, j'utilise les broches SPI pour l'écran TFT...

    Je devrais donc utiliser
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
    au lieu de
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
    Problème, si je compile ce code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    // Programme qui fonctionne (écran TFT et dalle tactile) sur Arduino seul
    // Programme qui fonction aussi (écran TFT et dalle tactile) sur Arduino avec Ethernet Shield 2 officiel Arduino
    // L'écran TFT, la dalle tactile et le module Ethernet Shield 2 sont compatibles électriquement
     
    #include "Adafruit_GFX.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques    
    #include "Adafruit_ILI9341.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques
    #include "URTouch.h" // Ajouté au format ZIP         
     
      //On définit les broches pour la partie affichage
      #define TFT_CLK 13
      #define TFT_MISO 12
      #define TFT_MOSI 11
      //#define TFT_CS 10
      #define TFT_CS 0 // On change juste cette broche pour piloter aussi le module Ethernet avec le bus SPI
      #define TFT_DC 9
      #define TFT_RST 8
      //Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
     
      Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
     
      #define TFT_PWM_LED 6 // Un transistor PNP permet de piloter le rétroéclairage 
      // Il est possible d'ajuster le niveau de rétroéclairage en fonction de la luminosité ambiante grâce à une photodiode sur une entrée analogique
      // On peut réduire et éteindre le rétroéclairage après une période d'inactivité de la dalle tactile
      // Et réactiver le rétroéclairage en cas de notification
     
      //On définit les broches pour la partie tactile
      #define t_IRQ 5
      //#define t_MISO 4
      #define t_MISO 7 // La broche 4 est utilisée pour le lecteur SD de l'ethernet Shield
      #define t_MOSI 3
      #define t_CS 2
      #define t_SCK 1
      URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
     
    void setup() {
     
      int radius = 4;
     
      analogWrite(TFT_PWM_LED,128);
     
      tft.begin();
      tft.setRotation(0);
     
      ts.InitTouch(PORTRAIT);
      ts.setPrecision(PREC_EXTREME);
      tft.fillScreen(ILI9341_BLACK);
     
      tft.setTextColor(ILI9341_RED, ILI9341_BLACK);
      tft.setTextSize(2);
     
      tft.fillCircle(10, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(10, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(120, 160, radius, ILI9341_YELLOW);
     
    }
     
    void loop()
    {
      int retro;
      int x, y;
      char Buffer_DispXY[15];
      while (ts.dataAvailable())
      {
        ts.read();
        x = ts.getX();
        y = ts.getY();
     
        if ((x != -1) && (y != -1))
        {
          snprintf_P(Buffer_DispXY, sizeof(Buffer_DispXY), PSTR("X=%3d Y=%3d"), x, y);
          tft.setCursor(55, 5);
          tft.print(Buffer_DispXY);
          retro=y-10;
          if (retro<0) {retro=0;}
          if (retro>255) {retro=255;}
          analogWrite(TFT_PWM_LED,retro);
        }
      }
    }
    J'ai une erreur call of overloaded 'Adafruit_ILI9341(int, int, int)' is ambiguous

    Bizarement, le code fonctionne avec
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
      //On définit les broches pour la partie affichage
      #define TFT_CLK 13
      #define TFT_MISO 12
      #define TFT_MOSI 11
      //#define TFT_CS 10
      #define TFT_CS 0 // On change juste cette broche pour piloter aussi le module Ethernet avec le bus SPI
      #define TFT_DC 9
      #define TFT_RST 8
      Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
    Donc je ferais du "software SPI" avec les broches hardware SPI ???

    Plus étrange, j'avais testé ce code avec des broches différentes... (donc là ça aurait du faire du software SPI) ça ne fonctionnait pas

    Précision : la dalle tactile doit certainement utiliser elle aussi du software SPI, car elle est raccordée sur les broches suivantes :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
      //On définit les broches pour la partie tactile
      #define t_IRQ 5
      //#define t_MISO 4
      #define t_MISO 7 // La broche 4 est utilisée pour le lecteur SD de l'ethernet Shield
      #define t_MOSI 3
      #define t_CS 2
      #define t_SCK 1
      URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
    Il y a un truc que je n'ai pas essayé :
    - mettre la dalle tactile sur le hardware SPI avec le shield Ethernet
    - mettre l'écran TFT sur d'autres broches en software SPI

    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  7. #27
    Modérateur

    Avatar de Vincent PETIT
    Homme Profil pro
    Consultant en Systèmes Embarqués
    Inscrit en
    Avril 2002
    Messages
    3 187
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Consultant en Systèmes Embarqués
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Avril 2002
    Messages : 3 187
    Points : 11 568
    Points
    11 568
    Par défaut
    Re,
    En regardant le hard de l'afficheur, il y a quand même quelque chose d'anormal, tu peux mettre des pullup sur tous tes /CS (sauf le shield Ethernet, là elle y est, mais si le schéma dont tu as donné le lien, est bon alors elles ont été oubliées.)




    Citation Envoyé par electroremy Voir le message
    Donc je ferais du "software SPI" avec les broches hardware SPI ???
    Oui ça par contre c'est possiblement un problème surtout si c'est pas très très bien émulé.

    En SPI on doit régler CPOL et CPHA, et faire ça en soft ça peut être complexe. Je n'ai pas eu le temps de regarder dans les datasheets qu'elles étaient les réglages demandés par les esclaves.

    Nom : capture007.png
Affichages : 611
Taille : 74,2 Ko




    Citation Envoyé par electroremy Voir le message
    La solution : des transistors pour empêcher l'écran TFT de voir les signaux CK et MOSI si la broche CS est à l'état haut.
    Non, non, fait pas ça. C'est la solution de celui qui n'a rien compris
    La science ne nous apprend rien : c'est l'expérience qui nous apprend quelque chose.
    Richard Feynman

  8. #28
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Bonjour,

    Citation Envoyé par Vincent PETIT Voir le message
    Re,
    En regardant le hard de l'afficheur, il y a quand même quelque chose d'anormal, tu peux mettre des pullup sur tous tes /CS (sauf le shield Ethernet, là elle y est, mais si le schéma dont tu as donné le lien, est bon alors elles ont été oubliées.)
    D'abord merci d'avoir pris le temps de regarder

    Je ne comprends pas... la broche /CS est une entrée côté périphérique SPI et une sortie côté Arduino... Pourquoi avoir besoin de pullup ?

    Les sorties Arduino que j'utilise sont-elles à collecteur ouvert ?

    Citation Envoyé par Vincent PETIT Voir le message
    La solution : des transistors pour empêcher l'écran TFT de voir les signaux CK et MOSI si la broche CS est à l'état haut.

    Non, non, fait pas ça. C'est la solution de celui qui n'a rien compris
    C'est un conseil vu ici : https://www.2bitornot2bit.com/blog/h...s-with-arduino

    J'ai peut être trouvé une solution ici :https://forums.adafruit.com/viewtopic.php?f=31&t=69620

    "The problem is that the SD driver and the TFT driver both set up the SPI control register (SPCR) differently. To make the two drivers work together, you have to re-set the control register to the right configuration before you start with a series of operations."

    Résumons la situation :
    - Dans tous les cas Shield Ethernet et la dalle tactile fonctionne
    - Le TFT fonctionne tant que je ne commence pas à utiliser le Shield Ethernet
    je ne dois pas être si loin de la solution. C'est pas comme si rien ne fonctionnait

    Ce qui me chagrine c'est que pour ce projet je croyais avoir "joué la sécurité", j'ai choisi un Arduino UNO, un shield Ethernet officiel et un écran du commerce en me disant "ce sont des équipements répandus qui ont fait leur preuves depuis des années, je n'aurais aucun problème à les utiliser autant ne pas m'embêter à concevoir un circuit imprimé de A à Z avec un microcontrôleur et tout un tas de composants annexes, dont il faudra développer le code assembleur de A à Z"

    Je ne suis quand même pas le premier à vouloir faire fonctionner un module Ethernet et un écran TFT tactile ensemble...

    D'un autre côté si j'y arrive et que je publie mon projet ça aura du succès

    Je vais quand même tester l'histoire de la résistance pull-up c'est vite fait...

    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  9. #29
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Bonjour,

    je viens de découvrir autre chose.

    Lorsque j'essayais de remplacer
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
    J'avais une erreur call of overloaded 'Adafruit_ILI9341(int, int, int)' is ambiguous

    En éditant Adafruit_ILI9341.h et Adafruit_ILI9341.cpp j'ai trouvé pourquoi : une surcharge de la fonction Adafruit_ILI9341() pour ESP8266 faisait doublon
    J'ai donc mis les fonctions concernées en commentaire.

    J'ai d'abord laissé
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
    pour voir si le code fonctionne

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    // Programme qui fonctionne (écran TFT et dalle tactile) sur Arduino seul
    // Programme qui fonctionne aussi (écran TFT et dalle tactile) sur Arduino avec Ethernet Shield 2 officiel Arduino
    // L'écran TFT, la dalle tactile et le module Ethernet Shield 2 sont compatibles électriquement
     
    #include "Adafruit_GFX.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques    
    #include "Adafruit_ILI9341.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques
    #include "URTouch.h" // Ajouté au format ZIP         
     
      //On définit les broches pour la partie affichage
      #define TFT_CLK 13
      #define TFT_MISO 12
      #define TFT_MOSI 11
      //#define TFT_CS 10
      #define TFT_CS 0 // On change juste cette broche pour piloter aussi le module Ethernet avec le bus SPI
      #define TFT_DC 9
      #define TFT_RST 8
      Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
     
      //Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
     
      #define TFT_PWM_LED 6 // Un transistor PNP permet de piloter le rétroéclairage 
      // Il est possible d'ajuster le niveau de rétroéclairage en fonction de la luminosité ambiante grâce à une photodiode sur une entrée analogique
      // On peut réduire et éteindre le rétroéclairage après une période d'inactivité de la dalle tactile
      // Et réactiver le rétroéclairage en cas de notification
     
      //On définit les broches pour la partie tactile
      #define t_IRQ 5
      //#define t_MISO 4
      #define t_MISO 7 // La broche 4 est utilisée pour le lecteur SD de l'ethernet Shield
      #define t_MOSI 3
      #define t_CS 2
      #define t_SCK 1
      URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
     
     
    void setup() {
     
      int radius = 4;
     
      analogWrite(TFT_PWM_LED,128);
     
      tft.begin();
      tft.setRotation(0);
     
      ts.InitTouch(PORTRAIT);
      ts.setPrecision(PREC_EXTREME);
      tft.fillScreen(ILI9341_BLACK);
     
      tft.setTextColor(ILI9341_RED, ILI9341_BLACK);
      tft.setTextSize(2);
     
      tft.fillCircle(10, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(10, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(120, 160, radius, ILI9341_YELLOW);
     
    }
     
    void loop()
    {
      int retro;
      int x, y;
      char Buffer_DispXY[15];
      while (ts.dataAvailable())
      {
        ts.read();
        x = ts.getX();
        y = ts.getY();
     
        if ((x != -1) && (y != -1))
        {
          snprintf_P(Buffer_DispXY, sizeof(Buffer_DispXY), PSTR("X=%3d Y=%3d"), x, y);
          tft.setCursor(55, 5);
          tft.print(Buffer_DispXY);
          retro=y-10;
          if (retro<0) {retro=0;}
          if (retro>255) {retro=255;}
          analogWrite(TFT_PWM_LED,retro);
        }
      }
    }
    Ca fonctionne normalement (c'est le fameux code qui n'utilise pas le Shield Ethernet

    Maintenant, avec Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    // Programme qui fonctionne (écran TFT et dalle tactile) sur Arduino seul
    // Programme qui fonction aussi (écran TFT et dalle tactile) sur Arduino avec Ethernet Shield 2 officiel Arduino
    // L'écran TFT, la dalle tactile et le module Ethernet Shield 2 sont compatibles électriquement
     
    #include "Adafruit_GFX.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques    
    #include "Adafruit_ILI9341.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques
    #include "URTouch.h" // Ajouté au format ZIP         
     
      //On définit les broches pour la partie affichage
      #define TFT_CLK 13
      #define TFT_MISO 12
      #define TFT_MOSI 11
      //#define TFT_CS 10
      #define TFT_CS 0 // On change juste cette broche pour piloter aussi le module Ethernet avec le bus SPI
      #define TFT_DC 9
      #define TFT_RST 8
      //Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
     
      Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
     
      #define TFT_PWM_LED 6 // Un transistor PNP permet de piloter le rétroéclairage 
      // Il est possible d'ajuster le niveau de rétroéclairage en fonction de la luminosité ambiante grâce à une photodiode sur une entrée analogique
      // On peut réduire et éteindre le rétroéclairage après une période d'inactivité de la dalle tactile
      // Et réactiver le rétroéclairage en cas de notification
     
      //On définit les broches pour la partie tactile
      #define t_IRQ 5
      //#define t_MISO 4
      #define t_MISO 7 // La broche 4 est utilisée pour le lecteur SD de l'ethernet Shield
      #define t_MOSI 3
      #define t_CS 2
      #define t_SCK 1
      URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
     
     
    void setup() {
     
      int radius = 4;
     
      analogWrite(TFT_PWM_LED,128);
     
      tft.begin();
      tft.setRotation(0);
     
      ts.InitTouch(PORTRAIT);
      ts.setPrecision(PREC_EXTREME);
      tft.fillScreen(ILI9341_BLACK);
     
      tft.setTextColor(ILI9341_RED, ILI9341_BLACK);
      tft.setTextSize(2);
     
      tft.fillCircle(10, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(10, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(120, 160, radius, ILI9341_YELLOW);
     
    }
     
    void loop()
    {
      int retro;
      int x, y;
      char Buffer_DispXY[15];
      while (ts.dataAvailable())
      {
        ts.read();
        x = ts.getX();
        y = ts.getY();
     
        if ((x != -1) && (y != -1))
        {
          snprintf_P(Buffer_DispXY, sizeof(Buffer_DispXY), PSTR("X=%3d Y=%3d"), x, y);
          tft.setCursor(55, 5);
          tft.print(Buffer_DispXY);
          retro=y-10;
          if (retro<0) {retro=0;}
          if (retro>255) {retro=255;}
          analogWrite(TFT_PWM_LED,retro);
        }
      }
    }
    Et là, ça ne fonctionne plus

    Cela veut dire que depuis le début, je pilote mon écran TFT en faisant du software SPI sur les broches SPI (ce qui est aberrant)

    Tant qu'à faire, si je fais du software SPI, autant utiliser d'autres broches et pas les broches SPI...
    J'avais déjà essayé sans succès... je réessaye...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    // Programme qui fonctionne (écran TFT et dalle tactile) sur Arduino seul
    // Programme qui fonction aussi (écran TFT et dalle tactile) sur Arduino avec Ethernet Shield 2 officiel Arduino
    // L'écran TFT, la dalle tactile et le module Ethernet Shield 2 sont compatibles électriquement
     
    #include "Adafruit_GFX.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques    
    #include "Adafruit_ILI9341.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques
    #include "URTouch.h" // Ajouté au format ZIP         
     
      //On définit les broches pour la partie affichage
      #define TFT_CLK A0  //13
      #define TFT_MISO A1 //12
      #define TFT_MOSI A2 //11
     
      //#define TFT_CS 10
      #define TFT_CS 0 // On change juste cette broche pour piloter aussi le module Ethernet avec le bus SPI
      #define TFT_DC 9
      #define TFT_RST 8
      Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
     
     
      #define TFT_PWM_LED 6 // Un transistor PNP permet de piloter le rétroéclairage 
      // Il est possible d'ajuster le niveau de rétroéclairage en fonction de la luminosité ambiante grâce à une photodiode sur une entrée analogique
      // On peut réduire et éteindre le rétroéclairage après une période d'inactivité de la dalle tactile
      // Et réactiver le rétroéclairage en cas de notification
     
      //On définit les broches pour la partie tactile
      #define t_IRQ 5
      //#define t_MISO 4
      #define t_MISO 7 // La broche 4 est utilisée pour le lecteur SD de l'ethernet Shield
      #define t_MOSI 3
      #define t_CS 2
      #define t_SCK 1
      URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
     
     
    void setup() {
      pinMode(A0, OUTPUT);
      pinMode(A2, OUTPUT);
     
      int radius = 4;
     
      analogWrite(TFT_PWM_LED,128);
     
      tft.begin();
      tft.setRotation(0);
     
      ts.InitTouch(PORTRAIT);
      ts.setPrecision(PREC_EXTREME);
      tft.fillScreen(ILI9341_BLACK);
     
      tft.setTextColor(ILI9341_RED, ILI9341_BLACK);
      tft.setTextSize(2);
     
      tft.fillCircle(10, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(10, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(120, 160, radius, ILI9341_YELLOW);
     
    }
     
    void loop()
    {
      int retro;
      int x, y;
      char Buffer_DispXY[15];
      while (ts.dataAvailable())
      {
        ts.read();
        x = ts.getX();
        y = ts.getY();
     
        if ((x != -1) && (y != -1))
        {
          snprintf_P(Buffer_DispXY, sizeof(Buffer_DispXY), PSTR("X=%3d Y=%3d"), x, y);
          tft.setCursor(55, 5);
          tft.print(Buffer_DispXY);
          retro=y-10;
          if (retro<0) {retro=0;}
          if (retro>255) {retro=255;}
          analogWrite(TFT_PWM_LED,retro);
        }
      }
    }
    Et là, ça fonctionne !
    J'avais du faire une erreur de câblage lors de mon test précédent...

    Maintenant, l'essai ultime : Shield Ethernet + Dalle Tactile + Ecran TFT, tout sur des broches séparées...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    #include <SPI.h>
    #include <Ethernet.h>
     
    // Ethernet Shield 2 : communicates with both the W5500 and SD card using the SPI bus (through the ICSP header).
    // This is on digital pins 10, 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega.
    // On both boards, pin 10 is used to select the W5500 and pin 4 for the SD card. These pins cannot be used for general I/O.
    // On the Mega, the hardware SS pin, 53, is not used to select either the W5500 or the SD card, but it must be kept as an output or the SPI interface won't work.
     
    #include "Adafruit_GFX.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques    
    #include "Adafruit_ILI9341.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques
    #include "URTouch.h" // Ajouté au format ZIP      
     
      //On définit les broches pour la partie affichage
      #define TFT_CLK A0  //13
      #define TFT_MISO A1 //12
      #define TFT_MOSI A2 //11
      //#define TFT_CS 10
      #define TFT_CS 0 // On change juste cette broche pour piloter aussi le module Ethernet avec le bus SPI
      #define TFT_DC 9
      #define TFT_RST 8
      Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
     
      #define TFT_PWM_LED 6 // Un transistor PNP permet de piloter le rétroéclairage 
      // Il est possible d'ajuster le niveau de rétroéclairage en fonction de la luminosité ambiante grâce à une photodiode sur une entrée analogique
      // On peut réduire et éteindre le rétroéclairage après une période d'inactivité de la dalle tactile
      // Et réactiver le rétroéclairage en cas de notification
     
      //On définit les broches pour la partie tactile
      #define t_IRQ 5
      //#define t_MISO 4
      #define t_MISO 7 // La broche 4 est utilisée pour le lecteur SD de l'ethernet Shield
      #define t_MOSI 3
      #define t_CS 2
      #define t_SCK 1
      URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
     
     
    // Enter a MAC address and IP address for your controller below.
    // The IP address will be dependent on your local network:
    byte mac[] = {
      0xA8, 0x61, 0x0A, 0xAE, 0x75, 0xCA
    };
    IPAddress ip(192, 168, 123, 177);
     
    // Initialize the Ethernet server library
    // with the IP address and port you want to use
    // (port 80 is default for HTTP):
    EthernetServer server(80);
     
        char Buffer_DispXY[15];
        int sensorReading;
        int dernierx;
        int derniery;
     
    void setup() {
      pinMode(A0, OUTPUT);
      pinMode(A2, OUTPUT);
     
      int radius = 4;
      dernierx=-1;
      derniery=-1;
     
      analogWrite(TFT_PWM_LED,128);
     
      tft.begin();
      tft.setRotation(0);
     
      ts.InitTouch(PORTRAIT);
      ts.setPrecision(PREC_EXTREME);
      tft.fillScreen(ILI9341_BLACK);
     
      tft.setTextColor(ILI9341_RED, ILI9341_BLACK);
      tft.setTextSize(2);
     
      tft.fillCircle(10, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(10, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(120, 160, radius, ILI9341_YELLOW);
     
      sensorReading = 555;
      snprintf_P(Buffer_DispXY, sizeof(Buffer_DispXY), PSTR("A = %d"), sensorReading);
      tft.setCursor(55, 5);
      tft.print(Buffer_DispXY);
     
    /*
      // Open serial communications and wait for port to open:
      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
      }
      Serial.println("Ethernet WebServer Example");
    */
     
      // You can use Ethernet.init(pin) to configure the CS pin
      //Ethernet.init(10);  // Most Arduino shields
      //Ethernet.init(5);   // MKR ETH shield
      //Ethernet.init(0);   // Teensy 2.0
      //Ethernet.init(20);  // Teensy++ 2.0
      //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
      //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet
     
      // start the Ethernet connection and the server:
      Ethernet.begin(mac, ip);
     
      // Check for Ethernet hardware present
      if (Ethernet.hardwareStatus() == EthernetNoHardware) {
        //Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
        while (true) {
          delay(1); // do nothing, no point running without Ethernet hardware
        }
      }
      if (Ethernet.linkStatus() == LinkOFF) {
        //Serial.println("Ethernet cable is not connected.");
      }
     
      // start the server
      server.begin();
      //Serial.print("server is at ");
      //Serial.println(Ethernet.localIP());
    }
     
     
    void loop() {
        int retro;
        int x, y;
     
      // listen for incoming clients
      EthernetClient client = server.available();
      if (client) {
        //Serial.println("new client");
        // an http request ends with a blank line
        boolean currentLineIsBlank = true;
        while (client.connected()) {
          if (client.available()) {
            char c = client.read();
            //Serial.write(c);
            // if you've gotten to the end of the line (received a newline
            // character) and the line is blank, the http request has ended,
            // so you can send a reply
            if (c == '\n' && currentLineIsBlank) {
              // send a standard http response header
              client.println(F("HTTP/1.1 200 OK"));
              client.println(F("Content-Type: text/html"));
              client.println(F("Connection: close"));  // the connection will be closed after completion of the response
              client.println(F("Refresh: 5"));  // refresh the page automatically every 5 sec
              client.println();
              client.println(F("<!DOCTYPE HTML>"));
              client.println(F("<html>"));
              // output the value of each analog input pin
              for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
                sensorReading = analogRead(analogChannel);
                client.print(F("analog input "));
                client.print(analogChannel);
                client.print(F(" is "));
                client.print(sensorReading);
                client.println(F("<br />"));
              }
              client.print(F("TFT X="));
              client.print(dernierx);
              client.print(F(" Y="));
              client.print(derniery);
              client.println(F("</html>"));
              break;
            }
            if (c == '\n') {
              // you're starting a new line
              currentLineIsBlank = true;
            } else if (c != '\r') {
              // you've gotten a character on the current line
              currentLineIsBlank = false;
            }
          }
        }
        // give the web browser time to receive the data
        delay(1);
        // close the connection:
        client.stop();
        //Serial.println("client disconnected");
      }
     
        while (ts.dataAvailable())
      {
        ts.read();
        x = ts.getX();
        y = ts.getY();
     
        if ((x != -1) && (y != -1))
        {
          dernierx=x;
          derniery=y;
          snprintf_P(Buffer_DispXY, sizeof(Buffer_DispXY), PSTR("X=%3d Y=%3d"), x, y);
          delay(10);
          tft.setCursor(55, 5);
          tft.print(Buffer_DispXY);
          retro=y-10;
          if (retro<0) {retro=0;}
          if (retro>255) {retro=255;}
          analogWrite(TFT_PWM_LED,retro);
          delay(10);
        }
      }
    }
    Et là ça fonctionne

    Bon OK c'est crade :
    - Il n'y a plus que 3 broches de libres (en fait 4 car je n'utilise pas le MISO avec l'écran TFT - en fait 6 car finalement les /CS du TFT et de la dalle tactile je pourrais les mettre à la masse)
    - la dalle tactile est en software SPI au lieu d'utiliser le SPI
    - l'écran TFT est en software SPI au lieu d'utiliser le SPI
    - j'utilise 25164 octets (78%) de l'espace de stockage de programmes
    - j'utilise 558 octets (27%)
    - l'écriture sur l'écran TFT est lent

    Il y a des optimisations à faire...

    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  10. #30
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    J'oubliais la photo de la solution crade

    Nom : Dsc03612.jpg
Affichages : 601
Taille : 686,7 Ko
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  11. #31
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Bonjour,

    voici le code de calibration de l'écran tactile qui va avec mon montage (indispensable avec la bibliothèque URTouch) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    // URTouch_Calibration 
    // Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
    // web: http://www.RinkyDinkElectronics.com/
    //
    // This program can be used to calibrate the touchscreen
    // of the display modules.
    // This program requires the UTFT library and a touch
    // screen module that is compatible with UTFT.
    //
    // It is assumed that the display module is connected to an
    // appropriate shield or that you know how to change the pin 
    // numbers in the setup.
    //
    // Instructions will be given on the display.
    //
     
    #include <UTFT.h>
    #include <URTouch.h>
     
    // Define the orientation of the touch screen. Further 
    // information can be found in the instructions.
    #define TOUCH_ORIENTATION  PORTRAIT
     
    //On définit les broches pour la partie affichage
      #define TFT_CLK A0  //13
      #define TFT_MISO A1 //12
      #define TFT_MOSI A2 //11
      #define TFT_CS 0 // On change juste cette broche pour piloter aussi le module Ethernet avec le bus SPI
      #define TFT_DC 9
      #define TFT_RST 8
    UTFT    myGLCD(ILI9341_S5P,TFT_MOSI,TFT_CLK,TFT_CS,TFT_RST,TFT_DC);
     
      #define TFT_PWM_LED 6 // Un transistor PNP permet de piloter le rétroéclairage 
     
    //On définit les broches pour la partie tactile
      #define t_IRQ 5
      #define t_MISO 7 // La broche 4 est utilisée pour le lecteur SD de l'ethernet Shield
      #define t_MOSI 3
      #define t_CS 2
      #define t_SCK 1
    URTouch  myTouch(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
     
    // ************************************
    // DO NOT EDIT ANYTHING BELOW THIS LINE
    // ************************************
     
    // Declare which fonts we will be using
    extern uint8_t SmallFont[];
     
    uint32_t cx, cy;
    uint32_t rx[8], ry[8];
    uint32_t clx, crx, cty, cby;
    float px, py;
    int dispx, dispy, text_y_center;
    uint32_t calx, caly, cals;
    char buf[13];
     
    void setup()
    {
      pinMode(A0, OUTPUT);
      pinMode(A2, OUTPUT);
      analogWrite(TFT_PWM_LED,128);
     
     
      myGLCD.InitLCD();
      myGLCD.clrScr();
      myGLCD.setFont(SmallFont);
     
      myTouch.InitTouch(TOUCH_ORIENTATION);
      dispx=myGLCD.getDisplayXSize();
      dispy=myGLCD.getDisplayYSize();
      text_y_center=(dispy/2)-6;
    }
     
    void drawCrossHair(int x, int y)
    {
      myGLCD.drawRect(x-10, y-10, x+10, y+10);
      myGLCD.drawLine(x-5, y, x+5, y);
      myGLCD.drawLine(x, y-5, x, y+5);
    }
     
    void readCoordinates()
    {
      int iter = 5000;
      int failcount = 0;
      int cnt = 0;
      uint32_t tx=0;
      uint32_t ty=0;
      boolean OK = false;
     
      while (OK == false)
      {
        myGLCD.setColor(255, 255, 255);
        myGLCD.print(F("*  PRESS  *"), CENTER, text_y_center);
        while (myTouch.dataAvailable() == false) {}
        myGLCD.print(F("*  HOLD!  *"), CENTER, text_y_center);
        while ((myTouch.dataAvailable() == true) && (cnt<iter) && (failcount<10000))
        {
          myTouch.calibrateRead();
          if (!((myTouch.TP_X==65535) || (myTouch.TP_Y==65535)))
          {
            tx += myTouch.TP_X;
            ty += myTouch.TP_Y;
            cnt++;
          }
          else
            failcount++;
        }
        if (cnt>=iter)
        {
          OK = true;
        }
        else
        {
          tx = 0;
          ty = 0;
          cnt = 0;
        }
        if (failcount>=10000)
          fail();
      }
     
      cx = tx / iter;
      cy = ty / iter;
    }
     
    void calibrate(int x, int y, int i)
    {
      myGLCD.setColor(255, 255, 255);
      drawCrossHair(x,y);
      myGLCD.setBackColor(255, 0, 0);
      readCoordinates();
      myGLCD.setColor(255, 255, 255);
      myGLCD.print("* RELEASE *", CENTER, text_y_center);
      myGLCD.setColor(80, 80, 80);
      drawCrossHair(x,y);
      rx[i]=cx;
      ry[i]=cy;
      while (myTouch.dataAvailable() == true) {}
    }
     
    void waitForTouch()
    {
      while (myTouch.dataAvailable() == true) {}
      while (myTouch.dataAvailable() == false) {}
      while (myTouch.dataAvailable() == true) {}
    }
     
    void toHex(uint32_t num)
    {
      buf[0] = '0';
      buf[1] = 'x';
      buf[10] = 'U';
      buf[11] = 'L';
      buf[12] = 0;
      for (int zz=9; zz>1; zz--)
      {
        if ((num & 0xF) > 9)
          buf[zz] = (num & 0xF) + 55;
        else
          buf[zz] = (num & 0xF) + 48;
        num=num>>4;
      }
    }
     
    void startup()
    {
      myGLCD.setColor(255, 0, 0);
      myGLCD.fillRect(0, 0, dispx-1, 13);
      myGLCD.setColor(255, 255, 255);
      myGLCD.setBackColor(255, 0, 0);
      myGLCD.drawLine(0, 14, dispx-1, 14);
      myGLCD.print(F("URTouch Calibration"), CENTER, 1);
      myGLCD.setBackColor(0, 0, 0);
     
      if (dispx==220)
      {  
        myGLCD.print(F("Use a stylus or something"), LEFT, 30);
        myGLCD.print(F("similar to touch as close"), LEFT, 42);
        myGLCD.print(F("to the center of the"), LEFT, 54);
        myGLCD.print(F("highlighted crosshair as"), LEFT, 66);
        myGLCD.print(F("possible. Keep as still as"), LEFT, 78);
        myGLCD.print(F("possible and keep holding"), LEFT, 90);
        myGLCD.print(F("until the highlight is"), LEFT, 102);
        myGLCD.print(F("removed. Repeat for all"), LEFT, 114);
        myGLCD.print(F("crosshairs in sequence."), LEFT, 126);
        myGLCD.print(F("Touch screen to continue"), CENTER, 162);
      }
      else
      {
        myGLCD.print(F("INSTRUCTIONS"), CENTER, 30);
        myGLCD.print(F("Use a stylus or something similar to"), LEFT, 50);
        myGLCD.print(F("touch as close to the center of the"), LEFT, 62);
        myGLCD.print(F("highlighted crosshair as possible. Keep"), LEFT, 74);
        myGLCD.print(F("as still as possible and keep holding"), LEFT, 86);
        myGLCD.print(F("until the highlight is removed. Repeat"), LEFT, 98);
        myGLCD.print(F("for all crosshairs in sequence."), LEFT, 110);
     
        myGLCD.print(F("Further instructions will be displayed"), LEFT, 134);
        myGLCD.print(F("when the calibration is complete."), LEFT, 146);
     
        myGLCD.print(F("Do NOT use your finger as a calibration"), LEFT, 170);
        myGLCD.print(F("stylus or the result WILL BE imprecise."), LEFT, 182);
     
        myGLCD.print(F("Touch screen to continue"), CENTER, 226);
      }
     
      waitForTouch();
      myGLCD.clrScr();
    }
     
    void done()
    {
      myGLCD.clrScr();
      myGLCD.setColor(255, 0, 0);
      myGLCD.fillRect(0, 0, dispx-1, 13);
      myGLCD.setColor(255, 255, 255);
      myGLCD.setBackColor(255, 0, 0);
      myGLCD.drawLine(0, 14, dispx-1, 14);
      myGLCD.print(F("URTouch Calibration"), CENTER, 1);
      myGLCD.setBackColor(0, 0, 0);
     
      if (dispx==220)
      {  
        myGLCD.print(F("To use the new calibration"), LEFT, 30);
        myGLCD.print(F("settings you must edit the"), LEFT, 42);
        myGLCD.setColor(160, 160, 255);
        myGLCD.print(F("URTouchCD.h"), LEFT, 54);
        myGLCD.setColor(255, 255, 255);
        myGLCD.print(F("file and change"), 88, 54);
        myGLCD.print(F("the following values. The"), LEFT, 66);
        myGLCD.print(F("values are located right"), LEFT, 78);
        myGLCD.print(F("below the opening comment."), LEFT, 90);
        myGLCD.print(F("CAL_X"), LEFT, 110);
        myGLCD.print(F("CAL_Y"), LEFT, 122);
        myGLCD.print(F("CAL_S"), LEFT, 134);
        toHex(calx);
        myGLCD.print(buf, 75, 110);
        toHex(caly);
        myGLCD.print(buf, 75, 122);
        toHex(cals);
        myGLCD.print(buf, 75, 134);
      }
      else
      {  
        myGLCD.print(F("CALIBRATION COMPLETE"), CENTER, 30);
        myGLCD.print(F("To use the new calibration"), LEFT, 50);
        myGLCD.print(F("settings you must edit the"), LEFT, 62);
        myGLCD.setColor(160, 160, 255);
        myGLCD.print(F("URTouchCD.h"), LEFT, 74);
        myGLCD.setColor(255, 255, 255);
        myGLCD.print(F("file and change"), 88, 74);
        myGLCD.print(F("the following values."), LEFT, 86);
        myGLCD.print(F("The values are located right"), LEFT, 98);
        myGLCD.print(F("below the opening comment in"), LEFT, 110);
        myGLCD.print(F("the file."), LEFT, 122);
        myGLCD.print(F("CAL_X"), LEFT, 150);
        myGLCD.print(F("CAL_Y"), LEFT, 162);
        myGLCD.print(F("CAL_S"), LEFT, 174);
     
        toHex(calx);
        myGLCD.print(buf, 75, 150);
        toHex(caly);
        myGLCD.print(buf, 75, 162);
        toHex(cals);
        myGLCD.print(buf, 75, 174);
      }
     
    }
     
    void fail()
    {
      myGLCD.clrScr();
      myGLCD.setColor(255, 0, 0);
      myGLCD.fillRect(0, 0, dispx-1, 13);
      myGLCD.setColor(255, 255, 255);
      myGLCD.setBackColor(255, 0, 0);
      myGLCD.drawLine(0, 14, dispx-1, 14);
      myGLCD.print(F("URTouch Calibration FAILED"), CENTER, 1);
      myGLCD.setBackColor(0, 0, 0);
     
      myGLCD.print(F("Unable to read the position"), LEFT, 30);
      myGLCD.print(F("of the press. This is a"), LEFT, 42);
      myGLCD.print(F("hardware issue and can"), 88, 54);
      myGLCD.print(F("not be corrected in"), LEFT, 66);
      myGLCD.print(F("software."), LEFT, 78);
     
      while(true) {};
    }
     
    void loop()
    {
      startup();
     
      myGLCD.setColor(80, 80, 80);
      drawCrossHair(dispx-11, 10);
      drawCrossHair(dispx/2, 10);
      drawCrossHair(10, 10);
      drawCrossHair(dispx-11, dispy/2);
      drawCrossHair(10, dispy/2);
      drawCrossHair(dispx-11, dispy-11);
      drawCrossHair(dispx/2, dispy-11);
      drawCrossHair(10, dispy-11);
      myGLCD.setColor(255, 255, 255);
      myGLCD.setBackColor(255, 0, 0);
      myGLCD.print(F("***********"), CENTER, text_y_center-12);
      myGLCD.print(F("***********"), CENTER, text_y_center+12);
     
      calibrate(10, 10, 0);
      calibrate(10, dispy/2, 1);
      calibrate(10, dispy-11, 2);
      calibrate(dispx/2, 10, 3);
      calibrate(dispx/2, dispy-11, 4);
      calibrate(dispx-11, 10, 5);
      calibrate(dispx-11, dispy/2, 6);
      calibrate(dispx-11, dispy-11, 7);
     
      if (TOUCH_ORIENTATION == LANDSCAPE)
        cals=(long(dispx-1)<<12)+(dispy-1);
      else
        cals=(long(dispy-1)<<12)+(dispx-1);
     
      if (TOUCH_ORIENTATION == PORTRAIT)
        px = abs(((float(rx[2]+rx[4]+rx[7])/3)-(float(rx[0]+rx[3]+rx[5])/3))/(dispy-20));  // PORTRAIT
      else
        px = abs(((float(rx[5]+rx[6]+rx[7])/3)-(float(rx[0]+rx[1]+rx[2])/3))/(dispy-20));  // LANDSCAPE
     
      if (TOUCH_ORIENTATION == PORTRAIT)
      {
        clx = (((rx[0]+rx[3]+rx[5])/3));  // PORTRAIT
        crx = (((rx[2]+rx[4]+rx[7])/3));  // PORTRAIT
      }
      else
      {
        clx = (((rx[0]+rx[1]+rx[2])/3));  // LANDSCAPE
        crx = (((rx[5]+rx[6]+rx[7])/3));  // LANDSCAPE
      }
      if (clx<crx)
      {
        clx = clx - (px*10);
        crx = crx + (px*10);
      }
      else
      {
        clx = clx + (px*10);
        crx = crx - (px*10);
      }
     
      if (TOUCH_ORIENTATION == PORTRAIT)
        py = abs(((float(ry[5]+ry[6]+ry[7])/3)-(float(ry[0]+ry[1]+ry[2])/3))/(dispx-20));  // PORTRAIT
      else
        py = abs(((float(ry[0]+ry[3]+ry[5])/3)-(float(ry[2]+ry[4]+ry[7])/3))/(dispx-20));  // LANDSCAPE
     
      if (TOUCH_ORIENTATION == PORTRAIT)
      {
        cty = (((ry[5]+ry[6]+ry[7])/3));  // PORTRAIT
        cby = (((ry[0]+ry[1]+ry[2])/3));  // PORTRAIT
      }
      else
      {
        cty = (((ry[0]+ry[3]+ry[5])/3));  // LANDSCAPE
        cby = (((ry[2]+ry[4]+ry[7])/3));  // LANDSCAPE
      }
      if (cty<cby)
      {
        cty = cty - (py*10);
        cby = cby + (py*10);
      }
      else
      {
        cty = cty + (py*10);
        cby = cby - (py*10);
      }
     
      calx = (long(clx)<<14) + long(crx);
      caly = (long(cty)<<14) + long(cby);
      if (TOUCH_ORIENTATION == LANDSCAPE)
        cals = cals + (1L<<31);
     
      done();
      while(true) {}
    }
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  12. #32
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Bonsoir,

    j'ai trouvé ce post en anglais : https://forum.developer.sony.com/top...ay-sw-spi-does

    I played around with the drivers you linked to.
    And found that if you change the following line in Adafruit_SPITFT.h

    //void initSPI(uint32_t freq = 0, uint8_t spiMode = SPI_MODE0);
    void initSPI(uint32_t freq = 0, uint8_t spiMode = SPI_MODE3);
    or even better in Adafruit_ILI9341 line 189:

    initSPI(freq);
    to
    initSPI(freq, SPI_MODE3);
    you should get the desired result.

    Please give it a try and see if it works better.

    BR
    Karl
    J'ai recâblé le TFT sur les broches SPI, fait la modif, testé mon programme avec

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    ...
      //On définit les broches pour la partie affichage
      #define TFT_CLK 13
      #define TFT_MISO 12
      #define TFT_MOSI 11
      #define TFT_CS 0
      #define TFT_DC 9
      #define TFT_RST 8
      Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
    ...
    Mais rien à faire, ça ne fonctionne pas...

    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  13. #33
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Le problème pourrait aussi venir des résistances :
    I wouldn't use a resistive divider on SPI.
    The resistors coupled with the gate capacitance form a low-pass filter limiting the maximum frequency you can reliably communicate at.
    Using software SPI you are going a lot slower, so it works better.
    You should use a proper active level shifter.
    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  14. #34
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Bonsoir,

    Voilà ça marche !

    Cette histoire de résistances... je me suis dit... il faut tester en baissant la vitesse...

    Dans Adafruit_ILI9341.cpp j'ai remplacé la ligne
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    initSPI(3000000, SPI_MODE3); //Pour que ça marche, il faut préciser une vitesse (possiblement plus élevée avec un convertisseur 5V/3.3V au lieu de résistances) et aussi le MODE3
    J'ai câblé mon écran TFT sur le bus SPI, et utilisé Adafruit avec le hardware SPI

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    #include <SPI.h>
    #include <Ethernet.h>
     
    // Ethernet Shield 2 : communicates with both the W5500 and SD card using the SPI bus (through the ICSP header).
    // This is on digital pins 10, 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega.
    // On both boards, pin 10 is used to select the W5500 and pin 4 for the SD card. These pins cannot be used for general I/O.
    // On the Mega, the hardware SS pin, 53, is not used to select either the W5500 or the SD card, but it must be kept as an output or the SPI interface won't work.
     
    #include "Adafruit_GFX.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques    
    #include "Adafruit_ILI9341.h" // Trouvé et ajouté via le menu Outil / Gérer les bibliothèques
    #include "URTouch.h" // Ajouté au format ZIP      
     
      //On définit les broches pour la partie affichage
      #define TFT_CLK 13
      #define TFT_MISO 12
      #define TFT_MOSI 11
      //#define TFT_CS 10
      #define TFT_CS 0 // On change juste cette broche pour piloter aussi le module Ethernet avec le bus SPI
      #define TFT_DC 9
      #define TFT_RST 8
      //Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
      Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
     
      #define TFT_PWM_LED 6 // Un transistor PNP permet de piloter le rétroéclairage 
      // Il est possible d'ajuster le niveau de rétroéclairage en fonction de la luminosité ambiante grâce à une photodiode sur une entrée analogique
      // On peut réduire et éteindre le rétroéclairage après une période d'inactivité de la dalle tactile
      // Et réactiver le rétroéclairage en cas de notification
     
      //On définit les broches pour la partie tactile
      #define t_IRQ 5
      //#define t_MISO 4
      #define t_MISO 7 // La broche 4 est utilisée pour le lecteur SD de l'ethernet Shield
      #define t_MOSI 3
      #define t_CS 2
      #define t_SCK 1
      URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
     
     
    // Enter a MAC address and IP address for your controller below.
    // The IP address will be dependent on your local network:
    byte mac[] = {
      0xA8, 0x61, 0x0A, 0xAE, 0x75, 0xCA
    };
    IPAddress ip(192, 168, 123, 177);
     
    // Initialize the Ethernet server library
    // with the IP address and port you want to use
    // (port 80 is default for HTTP):
    EthernetServer server(80);
     
        char Buffer_DispXY[15];
        int sensorReading;
        int dernierx;
        int derniery;
     
    void setup() {
      int radius = 4;
      dernierx=-1;
      derniery=-1;
     
      analogWrite(TFT_PWM_LED,128);
     
      tft.begin();
      tft.setRotation(0);
     
      ts.InitTouch(PORTRAIT);
      ts.setPrecision(PREC_EXTREME);
      tft.fillScreen(ILI9341_BLACK);
     
      tft.setTextColor(ILI9341_RED, ILI9341_BLACK);
      tft.setTextSize(2);
     
      tft.fillCircle(10, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(10, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 310, radius, ILI9341_YELLOW);
      tft.fillCircle(230, 10, radius, ILI9341_YELLOW);
      tft.fillCircle(120, 160, radius, ILI9341_YELLOW);
     
      sensorReading = 555;
      snprintf_P(Buffer_DispXY, sizeof(Buffer_DispXY), PSTR("A = %d"), sensorReading);
      tft.setCursor(55, 5);
      tft.print(Buffer_DispXY);
     
    /*
      // Open serial communications and wait for port to open:
      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
      }
      Serial.println("Ethernet WebServer Example");
    */
     
      // You can use Ethernet.init(pin) to configure the CS pin
      //Ethernet.init(10);  // Most Arduino shields
      //Ethernet.init(5);   // MKR ETH shield
      //Ethernet.init(0);   // Teensy 2.0
      //Ethernet.init(20);  // Teensy++ 2.0
      //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
      //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet
     
      // start the Ethernet connection and the server:
      Ethernet.begin(mac, ip);
     
      // Check for Ethernet hardware present
      if (Ethernet.hardwareStatus() == EthernetNoHardware) {
        //Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
        while (true) {
          delay(1); // do nothing, no point running without Ethernet hardware
        }
      }
      if (Ethernet.linkStatus() == LinkOFF) {
        //Serial.println("Ethernet cable is not connected.");
      }
     
      // start the server
      server.begin();
      //Serial.print("server is at ");
      //Serial.println(Ethernet.localIP());
    }
     
     
    void loop() {
        int retro;
        int x, y;
     
      // listen for incoming clients
      EthernetClient client = server.available();
      if (client) {
        //Serial.println("new client");
        // an http request ends with a blank line
        boolean currentLineIsBlank = true;
        while (client.connected()) {
          if (client.available()) {
            char c = client.read();
            //Serial.write(c);
            // if you've gotten to the end of the line (received a newline
            // character) and the line is blank, the http request has ended,
            // so you can send a reply
            if (c == '\n' && currentLineIsBlank) {
              // send a standard http response header
              client.println(F("HTTP/1.1 200 OK"));
              client.println(F("Content-Type: text/html"));
              client.println(F("Connection: close"));  // the connection will be closed after completion of the response
              client.println(F("Refresh: 5"));  // refresh the page automatically every 5 sec
              client.println();
              client.println(F("<!DOCTYPE HTML>"));
              client.println(F("<html>"));
              // output the value of each analog input pin
              for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
                sensorReading = analogRead(analogChannel);
                client.print(F("analog input "));
                client.print(analogChannel);
                client.print(F(" is "));
                client.print(sensorReading);
                client.println(F("<br />"));
              }
              client.print(F("TFT X="));
              client.print(dernierx);
              client.print(F(" Y="));
              client.print(derniery);
              client.println(F("</html>"));
              break;
            }
            if (c == '\n') {
              // you're starting a new line
              currentLineIsBlank = true;
            } else if (c != '\r') {
              // you've gotten a character on the current line
              currentLineIsBlank = false;
            }
          }
        }
        // give the web browser time to receive the data
        delay(1);
        // close the connection:
        client.stop();
        //Serial.println("client disconnected");
      }
     
        while (ts.dataAvailable())
      {
        ts.read();
        x = ts.getX();
        y = ts.getY();
     
        if ((x != -1) && (y != -1))
        {
          dernierx=x;
          derniery=y;
          snprintf_P(Buffer_DispXY, sizeof(Buffer_DispXY), PSTR("X=%3d Y=%3d"), x, y);
          tft.setCursor(55, 5);
          tft.print(Buffer_DispXY);
          retro=y-10;
          if (retro<0) {retro=0;}
          if (retro>255) {retro=255;}
          analogWrite(TFT_PWM_LED,retro);
        }
      }
    }
    Il faut donc :
    - forcer le MODE 3 du bus SPI
    - et aussi limiter la vitesse... avec 3000000 l'affichage est déjà 3 à 4 fois plus rapide qu'avec le software SPI

    J'ai testé avec une vitesse de 4000000 ça ne marche pas, mais mes connections sont longues et j'ai de bêtes résistances de 10K en série au lieu d'un vrai convertisseur...

    Il y a juste un petit truc un peu étrange...

    A chaque fois que le shield Ethernet est utilisé l'écran clignote légèrement (comme s'il y avait une perturbation du rétroéclairage).
    Cela n'arrivait pas lorsque l'écran était branché sur d'autres bornes que le SPI

    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  15. #35
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Bonjour,

    Le petit clignotement bizarre lorsque le Shield Ethernet fonctionne ne se produit plus si je débranche la borne MISO de l'écran TFT

    De toutes façon elle ne sert pas car dans mes programmes je ne lit pas de données depuis l'afficheur TFT

    Voilà un problème résolu !
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  16. #36
    Responsable Arduino et Systèmes Embarqués


    Avatar de f-leb
    Homme Profil pro
    Enseignant
    Inscrit en
    Janvier 2009
    Messages
    12 600
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Janvier 2009
    Messages : 12 600
    Points : 56 698
    Points
    56 698
    Billets dans le blog
    40
    Par défaut
    Bonjour,

    Bravo pour avoir réglé tous ces problèmes

    Par contre je suis un peu noyé dans ces explications et tous ces tests sur plus de 35 messages. Pourrais-tu résumer en un seul post toutes les modifications qui fonctionnent ?

  17. #37
    Membre éprouvé Avatar de electroremy
    Homme Profil pro
    Ingénieur sécurité
    Inscrit en
    Juin 2007
    Messages
    934
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Ingénieur sécurité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 934
    Points : 1 274
    Points
    1 274
    Par défaut
    Citation Envoyé par f-leb Voir le message
    Bonjour,

    Bravo pour avoir réglé tous ces problèmes

    Par contre je suis un peu noyé dans ces explications et tous ces tests sur plus de 35 messages. Pourrais-tu résumer en un seul post toutes les modifications qui fonctionnent ?
    Alors pour résumer :

    CABLAGE :
    - Le shield Ethernet utilise le bus SPI, ainsi que la broche 4 pour le lecteur SD intégré ; c'est un shield, il faut faire avec, et on ne massacre pas le shield à la pince coupante
    - L'écran TFT doit avoir sa broche CK et sa broche MOSI raccordées sur les broches SPI matérielles de l'Arduino
    - NE PAS câbler la broche MISO de l'écran TFT
    - Mette la broche /CS de l'écran TFT sur une autre broche (pas les broches SPI, ni la broche 4)
    - Câbler la dalle tactile sur d'autres broches qui sont utilisées pour rien d'autre

    CODE :
    - pour la dalle tactile utiliser URTouch.h, ça fonctionne bien (je n'ai pas cherché à utiliser le SPI matériel)
    - il faut utiliser Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); en définissant la valeur des broches TFT_CS, TFT_DC, TFT_RST avec #define
    - pour ne pas avoir l'erreur call of overloaded 'Adafruit_ILI9341(int, int, int)' is ambiguous il faut éditer Adafruit_ILI9341.h et Adafruit_ILI9341.cpp et mettre en commentaire les surcharges de la fonction Adafruit_ILI9341() pour ESP8266 qui font doublon car elles ont elles aussi trois paramètres
    - il faut éditer Adafruit_ILI9341.cpp et remplacer initSPI(freq); par initSPI(freq, SPI_MODE3);
    - enfin, dans le code, il faut appeler tft.begin(); avec en paramètre une vitesse compatible avec le câblage par exemple tft.begin(3000000);

    On peut mettre une vitesse plus élevée avec un câblage court et un adaptateur de niveau 5V/3,3V digne de ce nom et rapide (les résistances en série forment un filtre passe bas avec les capacités parasites des entrées logiques de l'afficheur, donc elles brident la vitesse)

    Je vais aller sur le forum de Adafruit et/ou leur envoyer un mail pour leur expliquer ce qu'il doivent corriger dans leur bibliothèque...

    C'est encore ça le mieux à faire pour éviter que tout le monde galère...
    Ou que tout le monde sous-exploite son matériel : combien se font couillonner en faisant du software SPI très lent sur les broches SPI matériel parce que sans mes modifs qui corrigent les bugs de la librairie, on ne peut pas faire autrement ? Surtout que si on n’épluche pas le code de la librairie, difficile de savoir que
    - Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO); c'est du software SPI
    - Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST) du hardware SPI
    Avoir deux constructeurs avec des noms explicites ça n'aurait pas été du luxe

    C'est ça qui est un peu dommage avec le monde de l'open source... les références officielles sont plutôt succinctes, on se perd dans les forks qui se multiplient, on trouve plein de tutoriels mauvais ou qui ne vont pas au fond des choses, les bonnes infos sont éparpillées dans des forums telles des aiguilles dans des bottes de foin.
    Pour ne rien arranger fabricants de clones et vendeurs de matériel ne maîtrisent pas les aspects logiciels et sont souvent incapables de fournir un manuel complet avec un exemple de code source optimal et propre.
    Ajoutons à cela du matériel qui peut être défectueux ou ne pas respecter les spécifications (plus jamais je n’achèterais les modules Ethernet SPI W5100 à bas coût)
    Bref un problème sur Arduino peut avoir tellement de causes que le débogage est parfois un vrai défit !

    A bientôt
    Quand deux personnes échangent un euro, chacun repart avec un euro.
    Quand deux personnes échangent une idée, chacun repart avec deux idées.

  18. #38
    Expert éminent sénior
    Avatar de Auteur
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    7 647
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 7 647
    Points : 11 136
    Points
    11 136
    Par défaut
    Bonsoir,

    bravo à toi.
    Une question : qu'appelles-tu le SPI software et le SPI Hardware ?

  19. #39
    Expert confirmé

    Homme Profil pro
    mad scientist :)
    Inscrit en
    Septembre 2019
    Messages
    2 711
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : mad scientist :)

    Informations forums :
    Inscription : Septembre 2019
    Messages : 2 711
    Points : 5 390
    Points
    5 390
    Par défaut
    Citation Envoyé par electroremy Voir le message
    combien se font couillonner en faisant du software SPI très lent sur les broches SPI matériel parce que sans mes modifs qui corrigent les bugs de la librairie, on ne peut pas faire autrement ? Surtout que si on n’épluche pas le code de la librairie, difficile de savoir que
    - Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO); c'est du software SPI
    - Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST) du hardware SPI
    Avoir deux constructeurs avec des noms explicites ça n'aurait pas été du luxe
    Hum, d’une part on est dans le logiciel libre, donc bien souvent la doc est dans le code source et ils sont très clair sur le Hardware SPI versus Software:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
     /**************************************************************************/
    /*!
        @brief  Instantiate Adafruit ILI9341 driver with software SPI
        @param    cs    Chip select pin #
        @param    dc    Data/Command pin #
        @param    mosi  SPI MOSI pin #
        @param    sclk  SPI Clock pin #
        @param    rst   Reset pin # (optional, pass -1 if unused)
        @param    miso  SPI MISO pin # (optional, pass -1 if unused)
    */
    /**************************************************************************/
    Adafruit_ILI9341::Adafruit_ILI9341(int8_t cs, int8_t dc, int8_t mosi,
                                       int8_t sclk, int8_t rst, int8_t miso)
        : Adafruit_SPITFT(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT, cs, dc, mosi, sclk,
                          rst, miso) {}
    
    /**************************************************************************/
    /*!
        @brief  Instantiate Adafruit ILI9341 driver with hardware SPI using the
                default SPI peripheral.
        @param  cs   Chip select pin # (OK to pass -1 if CS tied to GND).
        @param  dc   Data/Command pin # (required).
        @param  rst  Reset pin # (optional, pass -1 if unused).
    */
    /**************************************************************************/
    Adafruit_ILI9341::Adafruit_ILI9341(int8_t cs, int8_t dc, int8_t rst)
        : Adafruit_SPITFT(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT, cs, dc, rst) {}
    Ensuite leur code fonctionne peut être avec leur écran... si vous avez un clone il se peut qu’il y ait des différences suffisantes pour créer des soucis...

    Cela dit, gros bravo pour la persévérance et cette résolution de votre besoin !!

  20. #40
    Expert confirmé

    Homme Profil pro
    mad scientist :)
    Inscrit en
    Septembre 2019
    Messages
    2 711
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : mad scientist :)

    Informations forums :
    Inscription : Septembre 2019
    Messages : 2 711
    Points : 5 390
    Points
    5 390
    Par défaut
    Citation Envoyé par Auteur Voir le message
    Une question : qu'appelles-tu le SPI software et le SPI Hardware ?
    Il y a des bibliothèques qui font du SPI en «*bit banging*» tout en logiciel - (un peu comme software serial émule port série matériel ils gèrent du SPI à la main)

    Bien sûr c’est plus lent que quand c’est en matériel !!

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 3 PremièrePremière 123 DernièreDernière

Discussions similaires

  1. Arduino UNO + USB HOST Shield DUINOFUN
    Par fred2355 dans le forum Arduino
    Réponses: 9
    Dernier message: 26/04/2019, 21h55
  2. Réponses: 4
    Dernier message: 01/12/2018, 13h31
  3. Réponses: 2
    Dernier message: 31/12/2015, 10h11
  4. TFT TACTILE ADC STM32F1
    Par boby6613 dans le forum C
    Réponses: 8
    Dernier message: 26/04/2012, 15h17
  5. Réponses: 8
    Dernier message: 24/08/2006, 12h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo