Forum Rule: Always post complete source code & details to reproduce any issue!
Page 4 of 4 FirstFirst ... 2 3 4
Results 76 to 82 of 82

Thread: Display_ili9341

  1. #76
    Junior Member
    Join Date
    Jul 2020
    Posts
    3
    Quote Originally Posted by KurtE View Post
    Sorry, I am not sure what you have or don't have? Maybe post a picture of your display? I believe I still have some of the first ones PJRC released, which would work fine with the different displays. However I am not sure how well the SDCards worked. I believe it was mostly suggested to not use them. But again I am not sure if much of this has changed since then.
    Here is the display I got from PJRC:
    Click image for larger version. 

Name:	IMG_20200722_081409.jpg 
Views:	9 
Size:	75.4 KB 
ID:	21078

  2. #77
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,609
    You should be able to make the same change to this display like HWGuy did in the thread: https://forum.pjrc.com/threads/28106...ll=1#post72889

    Where he removed the three resistors and replaced them with 0Ohm. Can probably maybe solder bridge it as well.
    Not sure if his other changes are necessary or not. Like the Solder jumper. My guess is that this bypasses the 5v to 3.3v VR on the board. So Vin can go directly to 3.3v instead of the higher voltage. But he then shows external Pull up resistors. Not sure if the external PU resistors he shows would be necessary or not on the SPI pins with this modification.

    Again I have not used the SD Card slots on these displays.

  3. #78
    Senior Member
    Join Date
    May 2017
    Posts
    106
    Quote Originally Posted by KurtE View Post
    You should be able to make the same change to this display like HWGuy did in the thread: https://forum.pjrc.com/threads/28106...ll=1#post72889

    Where he removed the three resistors and replaced them with 0Ohm. Can probably maybe solder bridge it as well.
    Not sure if his other changes are necessary or not. Like the Solder jumper. My guess is that this bypasses the 5v to 3.3v VR on the board. So Vin can go directly to 3.3v instead of the higher voltage. But he then shows external Pull up resistors. Not sure if the external PU resistors he shows would be necessary or not on the SPI pins with this modification.

    Again I have not used the SD Card slots on these displays.
    The pull ups are necessary. Otherwise you will get problems reading SD Card (wich I had).

  4. #79
    Senior Member
    Join Date
    Jan 2015
    Location
    France
    Posts
    117
    Hello,

    I'm looking for a convenient way to allow short press and long press on the display. Is there an easy way to do it ?

    Actually my code is this :

    Code:
    void loop() {
        if (ts.touched()) {                             // L'ecran a été touché, faire tourner les vues
          TS_Point p = ts.getPoint();
          if ((p.x >= 0) && (p.x <= 2500)) {
            ScreenChanged = false;
            if (num_screen != 0) {
              num_screen = num_screen - 1;
            }
            else {
              num_screen = 2;
            }
            changeScreen(num_screen);
            unsigned long currentMillis = millis();
            while (millis() < (currentMillis + debounceScreen));
          }
          else if ((p.x >= 2501) && (p.x <= 5000)) {
            ScreenChanged = false;
            num_screen = num_screen + 1;
            if (num_screen > 2) {
              num_screen = 0;
            }
            changeScreen(num_screen);
            unsigned long currentMillis = millis();
            while (millis() < (currentMillis + debounceScreen));
          }
        }
     }
    This code separate the screen in 2 areas, and in regard with the touched area the screen change from left to right, and vice-versa. My goal now is to allow detection of a long press on the screen (let's say 5secondes and more) to enter in a configuration mode.

    Thank you,
    Manu

  5. #80
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,321
    IIRC the one example set WasTouched in the if(ts.touched()) case. When setting that true the time could be recorded.

    Then in else case look for WasTouched being true and compare the time, and set WasTouched false. If the time between WasTouched and the release is >= 5 seconds then it would be the long press case.

  6. #81
    Senior Member
    Join Date
    Jan 2015
    Location
    France
    Posts
    117
    Quote Originally Posted by defragster View Post
    IIRC the one example set WasTouched in the if(ts.touched()) case. When setting that true the time could be recorded.

    Then in else case look for WasTouched being true and compare the time, and set WasTouched false. If the time between WasTouched and the release is >= 5 seconds then it would be the long press case.
    I'm sorry, but it's absolutely unclear :-(
    At least difficult to do (for me)

  7. #82
    Senior Member
    Join Date
    Jan 2015
    Location
    France
    Posts
    117
    I finally end with this code. It operate but I think it can be better :

    Code:
    #define debounceScreen 200    // Millisecondes
    #define longPress 3500
    
    bool wasTouched = false;
    bool wasReleased = false;
    bool config = false;
    unsigned long pressStart;
    
    void Screen_Config () {
      do something...
      config = false;
      return;
    }
    
    void loop() {
      if (Serial.available())                           // Mode configuration.
      {
        traiteCommandeFromSerialWithCRC();
      }
      if (TypeAfficheur == 0) {                         // L'afficheur est configuré en mode information
        if (ts.touched()) {                             // L'ecran a été touché, faire tourner les vues
          if (wasTouched == false) {
            pressStart = millis();
            wasReleased = false;
            wasTouched = true;
          }
        }
        else {
          if (wasTouched == true) {
            wasTouched = false;
            wasReleased = true;
          }
          if (((millis() - pressStart) >= longPress) && (wasReleased == true)) {
            pressStart = 0;
            wasReleased = false;
            config = true;
            Screen_Config();
          }
          else if (wasReleased == true  && (config == false)) {
            TS_Point p = ts.getPoint();
            if ((p.x >= 0) && (p.x <= 2500)) {
              ScreenChanged = false;
              if (num_screen != 0) {
                num_screen = num_screen - 1;
              }
              else {
                num_screen = 2;
              }
              changeScreen(num_screen);
              unsigned long currentMillis = millis();
              while (millis() < (currentMillis + debounceScreen));
            }
            else if ((p.x >= 2501) && (p.x <= 5000)) {
              ScreenChanged = false;
              num_screen = num_screen + 1;
              if (num_screen > 2) {
                num_screen = 0;
              }
              changeScreen(num_screen);
              unsigned long currentMillis = millis();
              while (millis() < (currentMillis + debounceScreen));
            }
            wasReleased = false;
          }
        }
      }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •