Forum Rule: Always post complete source code & details to reproduce any issue!
Page 12 of 12 FirstFirst ... 2 10 11 12
Results 276 to 299 of 299

Thread: RA8875 from Buydisplay

  1. #276
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    139
    Mike, Kurt,

    That did the job many thanks!
    Was made for a small screen so some work to do for the RA8875 display.

    Take care,
    Best,
    Johan
    Click image for larger version. 

Name:	DeepinScreenshot_select-area_20200319200952.jpg 
Views:	45 
Size:	56.2 KB 
ID:	19415

  2. #277
    Hey Guys,

    I might have missed it, but are we able to choose one of the secondary busses on the T4.x boards? If so is there a reference to how to?

  3. #278
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,009
    Quote Originally Posted by Dylpickle View Post
    Hey Guys,

    I might have missed it, but are we able to choose one of the secondary busses on the T4.x boards? If so is there a reference to how to?
    If I remember correctly we put the code in place to detect it, by which pin numbers you pass in. That is the constructor has:
    Code:
    		RA8875(const uint8_t CSp,const uint8_t RSTp=255,const uint8_t mosi_pin=11,const uint8_t sclk_pin=13,const uint8_t miso_pin=12);
    Yep when we were adding the code for T4.x we made it all use the SPI table driven functions to figure out which SPI buss to use. That is the code in the begin function does:
    Code:
    		//always uses SPI transaction 
    		if (SPI.pinIsMISO(_miso) && SPI.pinIsMOSI(_mosi) && SPI.pinIsSCK(_sclk)) {
    			_pspi = &SPI;
    		} else if (SPI1.pinIsMISO(_miso) && SPI1.pinIsMOSI(_mosi) && SPI1.pinIsSCK(_sclk)) {
    			_pspi = &SPI1;
    		} else if (SPI2.pinIsMISO(_miso) && SPI2.pinIsMOSI(_mosi) && SPI2.pinIsSCK(_sclk)) {
    			_pspi = &SPI2;
    		} else {
    			_errorCode |= (1 << 1);//set
    			return;
    		}
    		// Make sure we select the right pins.  
    		// On T4 does nothing, and on T4.1 only miso matters, but just in case.
    		_pspi->setMISO(_miso);
    		_pspi->setMOSI(_mosi);
    		_pspi->setSCK(_sclk);
    So again just pass in valid pins for MOSI, MISO and SCK and it will do the right thing

  4. #279
    Thanks Mate, I'm looking at buying one but wanted to make sure I have conflicts on other busses.

  5. #280
    Hi KurtE
    You help me couple times and I thank you.
    Please help me with this problem. I have a RA8875 + T4, and I want to display clock with Michroma font, I have this problem, please see the pictures
    Click image for larger version. 

Name:	IMG_1850.jpg 
Views:	14 
Size:	91.5 KB 
ID:	23286
    Click image for larger version. 

Name:	IMG_1852.jpg 
Views:	15 
Size:	82.8 KB 
ID:	23287
    This is part of me code

    tft.setTextColor(RA8875_WHITE, RA8875_BLACK);
    tft.setCursor(345, 10);

    if (hh < 10){
    tft.print("0");
    xpos += pix;
    }

    tft.print(hh);
    xpos += pix;

    tft.print(":");
    xpos += pix;

    if (mm < 10){
    tft.print("0");
    xpos += pix;
    }

    tft.print(mm);
    xpos += pix;

    tft.print(":");
    xpos += pix;

    if (sss < 10){
    tft.print("0");
    xpos += pix;
    }

    tft.print(sss);

    Please tell me some solution to fix this.
    Thank you in advance

  6. #281
    Member KD0RC's Avatar
    Join Date
    May 2019
    Location
    Colorado, USA
    Posts
    79
    I think the problem you are having is that new characters just overlay what is already on the screen. Here is a typical thing that I do to clear the portion of the screen in preparation for new characters:

    Code:
        tft.fillRect(0, 290, 110, 20, HX8357_BLACK);  // Blank slate for new value
        tft.setFont(Arial_14);
        tft.setTextColor(HX8357_YELLOW);
        tft.setCursor(0,290);
        tft.print("RF Pwr: "); tft.print(fRig.transmit.rfpower);
    I make the rectangle of black (or whatever the background color is) so that it just covers the characters to be erased. To make it easy to see what the rectangle will do, I often do a tft.drawRect with a color of white. After adjusting the x and y coordinates, I change it to fillRect with a color of black.

  7. #282
    Thank you
    In this case, I have to move the rectangle and change the weight, I was hopping there is better way to fix this, like using layers or some kind of "active window"
    to put the clock inside.

  8. #283
    Member KD0RC's Avatar
    Join Date
    May 2019
    Location
    Colorado, USA
    Posts
    79
    The problem with my method is that rapidly changing values can induce flicker. Another approach is to save the current value of each character or characters to be updated. At update time, rewrite the old value in background color, then write the new value. If the characters have variable width, this can be problematic, so you have to re-write everything to the right of the character being changed. For character sets with the same width for all characters, this is no problem - just rewrite the changing char.

  9. #284
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,009
    Sorry I really don't know the RA887x that well to know how all of the different fonts work or not. I believe this is NOT a system font so we are simply drawing the bits.
    Again I also mostly just putter and don't do any real products. (Retired)...

    But with my own stuff what I have often done with logical fields like this is something like: Warning, I am doing sort of valid stuff, but may not be fully correct (typing on fly not studying headers)

    a) simple approach: If I know that my text is supposed to be in some rectangle field:
    I do something like:
    Code:
      tft.setTextColor(fgColor, bgColor
      tft.setCursor(fieldX, FieldY)'
      tft.drawText(newtime);
      int16_t xcursor = tft.getCursorX();
      tft.fillRect(xCursor, fieldY, (fieldX_end - xcursor), field_height);
    So you fill everything to the right of your current text in the field with background color

    b) slightly smarter like above, but instead of filling whole field to right. you remember how far to the right the previous write went and only if your new right is < previous right, you
    fill from current right to last previous right...

  10. #285
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,969
    @KurtE
    Just wanted to know if you have your RA8875 display working with the T4x. For some reason its not working for me with the T4.1. I tried it with a T3.5 and it works without a problem?

  11. #286
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,009
    Quote Originally Posted by mjs513 View Post
    @KurtE
    Just wanted to know if you have your RA8875 display working with the T4x. For some reason its not working for me with the T4.1. I tried it with a T3.5 and it works without a problem?
    The one I am running is on a T4. Maybe you are setup with non-standard pins like T14 for SCK?

  12. #287
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,969
    Quote Originally Posted by KurtE View Post
    The one I am running is on a T4. Maybe you are setup with non-standard pins like T14 for SCK?
    No = using standard SPI pins - also checked the pins with the RA8876 which works. Really strange have to try and sort it out. Also am using my standard Display adapter board so it should work.

    EDIT - sorted it out right after I wrote this. Simple issue - bad ground. Now for playing.

  13. #288
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,009
    Glad you have it working.

    As I mentioned, the Opaque drawFontChar stuff is not working with clipping.

    Turns out the clipping code was only added into the Anti-aliased parts of the code. In the other libraries it is done above the branch to Anti-aliased or Aliased and after...
    Started doing it, but probably will take awhile to see how the code parts are different.

    But off to see how well the truck runs...

  14. #289
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,969
    Cool

    Been looking as well but trying to remember how all the pieces work together - been too long.

  15. #290
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,009
    Hi, was out doing other stuff.

    Here is updated test sketch which shows a few problems:
    Code:
    #include <Adafruit_GFX.h>
    
    #include <SPI.h>
    #include <RA8875.h>
    
    #include "font_Arial.h"
    #include "font_OpenSans.h"
    //****************************************************************************
    // Settings and objects
    //****************************************************************************
    
    #define RA8875_CS 9
    #define RA8875_RST 8
    RA8875 tft = RA8875(RA8875_CS, RA8875_RST);
    
    void drawTextWithBoundingRect(uint16_t x, uint16_t y, const char *str, ILI9341_t3_font_t *font) {
      int16_t x1, y1;
      uint16_t  w, h;
      tft.setFont(*font);
      tft.setCursor(x, y);
      tft.getTextBounds(str, x, y, &x1, &y1, &w, &h);
      tft.print(str);
      tft.drawRect(x1, y1, w, h, RA8875_RED);
    }
    
    void drawCenteredText(uint16_t x, uint16_t y, uint16_t w, uint16_t h,
                          const char *str,
                          ILI9341_t3_font_t *font,
                          uint16_t bg, uint16_t text_fg, uint16_t text_bg) {
      tft.setFont(*font);
      tft.fillRect(x, y, w, h, bg);
      if (text_fg == text_bg) tft.setTextColor(text_fg);
      else tft.setTextColor(text_fg, text_bg);
      tft.setCursor(x + w / 2, y + h / 2, true);
      tft.setClipRect(x, y, w, h);
      tft.print(str);
      tft.setClipRect();
    }
    
    void setup()
    {
      Serial.begin(9600);
      delay(3000);
      while (!Serial && millis() < 5000) ;
      Serial.println("Initializing TFT display");
    
      //  begin display: Choose from: RA8875_480x272, RA8875_800x480, RA8875_800x480ALT, Adafruit_480x272, Adafruit_800x480
      tft.begin(Adafruit_800x480, 16, 15000000);
    
      tft.fillWindow(RA8875_BLACK);
      tft.setTextColor(RA8875_YELLOW);
      tft.setTextSize(2);
      tft.setRotation(1);
    
      tft.setFont(Arial_40);
    
      drawTextWithBoundingRect(20, 20, "-", &Arial_40);
      drawTextWithBoundingRect(60, 20, "+", &Arial_40);
      drawTextWithBoundingRect(100, 20, "X", &Arial_40);
      drawTextWithBoundingRect(140, 20, "Next", &Arial_40);
    
      drawCenteredText(20, 100, 35, 50, "-", &Arial_40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(60, 100, 35, 50,  "+", &Arial_40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(100, 100, 40, 50,  "X", &Arial_40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(150, 100, 130, 50,  "Next", &Arial_40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
    
      drawCenteredText(20, 200, 35, 50, "-", &Arial_40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(60, 200, 35, 50,  "+", &Arial_40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(100, 200, 40, 50,  "X", &Arial_40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(150, 200, 130, 50,  "Next", &Arial_40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
    
      drawTextWithBoundingRect(20, 300, "-", &OpenSans40);
      drawTextWithBoundingRect(60, 300, "+", &OpenSans40);
      drawTextWithBoundingRect(100, 300, "X", &OpenSans40);
      drawTextWithBoundingRect(140, 300, "Next", &OpenSans40);
    
      drawCenteredText(20, 400, 35, 50, "-", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(60, 400, 35, 50,  "+", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(100, 400, 40, 50,  "X", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(150, 400, 130, 50,  "Next", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
    
      drawCenteredText(20, 500, 35, 50, "-", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(60, 500, 35, 50,  "+", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(100, 500, 40, 50,  "X", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(150, 500, 130, 50,  "Next", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
    
    }
    
    
    void loop(void)
    {
    }
    Probably not the cleanest sketch in the world
    Click image for larger version. 

Name:	IMG_1349.jpg 
Views:	12 
Size:	63.2 KB 
ID:	24056
    But first half shows the aliased fonts... top line centering stuff, next line Opaque text, next Transparent. Then repeat for anti-aliased font...

  16. #291
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,969
    [DELETED}

    I rewrote your example sketch a bit so can use on multiple displays.
    Code:
    #include <Adafruit_GFX.h>
    
    //#define HAS_9488
    //#define HAS_8357
    #define HAS_8875
    
    #include <SPI.h>
    #ifdef HAS_9488
    #include "ILI9488_t3.h"
    #elif defined(HAS_8357)
    #include "HX8357_t3n.h"
    #elif defined(HAS_8875)
    #include "RA8875.h"
    #endif
    
    #define Arial_40          Arial_40
    #define OpenSans40        OpenSans40
    
    //-----------------------------------------------------
    #include "font_Arial.h"
    #include "font_OpenSans.h"
    //****************************************************************************
    // Settings and objects
    //****************************************************************************
    
    
    // For the Adafruit shield, these are the default.
    #define TFT_DC  9
    #define TFT_CS 10
    #define TFT_RST 8
    
    // Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
    #include <SPI.h>
    #ifdef HAS_9488
    ILI9488_t3 tft = ILI9488_t3(&SPI, TFT_CS, TFT_DC, TFT_RST);
    #elif defined(HAS_8357)
    HX8357_t3n tft = HX8357_t3n(TFT_CS, TFT_DC, TFT_RST);
    #elif defined(HAS_8875)
    RA8875 tft = RA8875(TFT_CS, TFT_RST);
    #endif
    
    
    #ifdef HAS_9488
    #define RA8875_RED        ILI9488_RED
    #define RA8875_YELLOW     ILI9488_YELLOW
    #define RA8875_BLUE       ILI9488_BLUE
    #define RA8875_BLACK      ILI9488_BLACK
    #elif defined(HAS_8357)
    #define RA8875_BLACK      HX8357_BLACK
    #define RA8875_RED        HX8357_RED
    #define RA8875_YELLOW     HX8357_YELLOW
    #define RA8875_BLUE       HX8357_BLUE
    #define RA8875_BLACK      HX8357_BLACK
    #endif
    
    uint16_t y_loc;
    
    void drawTextWithBoundingRect(uint16_t x, uint16_t y, const char *str, ILI9341_t3_font_t *font) {
      int16_t x1, y1;
      uint16_t  w, h;
      tft.setFont(*font);
      tft.setCursor(x, y);
      tft.getTextBounds(str, x, y, &x1, &y1, &w, &h);
      tft.print(str);
      tft.drawRect(x1, y1, w, h, RA8875_RED);
    }
    
    void drawCenteredText(uint16_t x, uint16_t y, uint16_t w, uint16_t h,
                          const char *str,
                          ILI9341_t3_font_t *font,
                          uint16_t bg, uint16_t text_fg, uint16_t text_bg) {
      tft.setFont(*font);
      tft.fillRect(x, y, w, h, bg);
      if (text_fg == text_bg) tft.setTextColor(text_fg);
      else tft.setTextColor(text_fg, text_bg);
      tft.setCursor(x + w / 2, y + h / 2, true);
      tft.setClipRect(x, y, w, h);
      tft.print(str);
      tft.setClipRect();
    }
    
    
    void nextPage()
    {
      Serial.println("Press anykey to continue");
      while (Serial.read() == -1) ;
      while (Serial.read() != -1) ;
    
      #ifdef HAS_8875
        tft.fillWindow(RA8875_BLACK);
      #else
        tft.fillScreen(RA8875_BLACK);
      #endif
    
      tft.setCursor(0, 0);
    }
    
    void setup()
    {
      Serial.begin(9600);
      delay(3000);
      while (!Serial && millis() < 5000) ;
      Serial.println("Initializing TFT display");
    
      //  begin display: Choose from: HX8357_480x272, HX8357_800x480, HX8357_800x480ALT, Adafruit_480x272, Adafruit_800x480
      #ifdef HAS_8875
          tft.begin(Adafruit_800x480, 16, 15000000);
          tft.fillWindow(RA8875_BLACK);
      #else
        tft.begin();
        tft.fillScreen(RA8875_BLACK);
      #endif
      
      tft.setTextColor(RA8875_YELLOW);
      tft.setTextSize(2);
      tft.setRotation(1);
    
    }
    
    
    void loop(void)
    {
      Serial.println("Arial");
      tft.setFont(Arial_40);
    
      drawTextWithBoundingRect(20, 20, "-", &Arial_40);
      drawTextWithBoundingRect(60, 20, "+", &Arial_40);
      drawTextWithBoundingRect(100, 20, "X", &Arial_40);
      drawTextWithBoundingRect(140, 20, "Next", &Arial_40);
    
      drawCenteredText(20, 80, 35, 50, "-", &Arial_40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(60, 80, 35, 50,  "+", &Arial_40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(100, 80, 40, 50,  "X", &Arial_40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(150, 80, 130, 50,  "Next", &Arial_40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
    
      drawCenteredText(20, 180, 35, 50, "-", &Arial_40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(60, 180, 35, 50,  "+", &Arial_40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(100, 180, 40, 50,  "X", &Arial_40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(150, 180, 130, 50,  "Next", &Arial_40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
    
      #if !defined(HAS_8875) 
      nextPage();
      Serial.println("OpenSans");
      drawTextWithBoundingRect(20, 20, "-", &OpenSans40);
      drawTextWithBoundingRect(60, 20, "+", &OpenSans40);
      drawTextWithBoundingRect(100, 20, "X", &OpenSans40);
      drawTextWithBoundingRect(140, 20, "Next", &OpenSans40);
    
      drawCenteredText(20, 80, 35, 50, "-", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(60, 80, 35, 50,  "+", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(100, 80, 40, 50,  "X", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(150, 80, 130, 50,  "Next", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
    
      drawCenteredText(20, 180, 35, 50, "-", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(60, 180, 35, 50,  "+", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(100, 180, 40, 50,  "X", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(150, 180, 130, 50,  "Next", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
    
      #else
      
      drawTextWithBoundingRect(20, 300, "-", &OpenSans40);
      drawTextWithBoundingRect(60, 300, "+", &OpenSans40);
      drawTextWithBoundingRect(100, 300, "X", &OpenSans40);
      drawTextWithBoundingRect(140, 300, "Next", &OpenSans40);
    
      drawCenteredText(20, 400, 35, 50, "-", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(60, 400, 35, 50,  "+", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(100, 400, 40, 50,  "X", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
      drawCenteredText(150, 400, 130, 50,  "Next", &OpenSans40, RA8875_YELLOW, RA8875_RED, RA8875_YELLOW);
    
      drawCenteredText(20, 500, 35, 50, "-", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(60, 500, 35, 50,  "+", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(100, 500, 40, 50,  "X", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
      drawCenteredText(150, 500, 130, 50,  "Next", &OpenSans40, RA8875_YELLOW, RA8875_BLUE, RA8875_BLUE);
    #endif
    
    nextPage();
    }
    Looks like for the ILI9488 and the HX8357 it works for Arial fonts but not for OpenSans40 fonts
    Last edited by mjs513; 03-14-2021 at 10:42 PM.

  17. #292
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,009
    I just put in a hack version that the opaque font code calls off to a new fillRect function that does clipping.

    The current code did not do any clipping... Not sure if it will impact other parts or not, but test cases appear to work better.

  18. #293
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,969
    Quote Originally Posted by KurtE View Post
    I just put in a hack version that the opaque font code calls off to a new fillRect function that does clipping.

    The current code did not do any clipping... Not sure if it will impact other parts or not, but test cases appear to work better.
    I already incorporated the PR I also just updated the test sketch.

  19. #294
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,969
    Ok finally got around to taking some pictures with the updated sketch.

    On the ILI9488 with aliased fonts, it looks ok:
    Click image for larger version. 

Name:	aliased.png 
Views:	8 
Size:	575.7 KB 
ID:	24057

    For anti-aliased i think I may have done something wrong, but it has issues:
    Click image for larger version. 

Name:	antialiased.png 
Views:	7 
Size:	461.2 KB 
ID:	24058

  20. #295
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    244

    Having trouble w/ RA8875 (TFTM070-5) w/ resistive touch panel

    Particulars:
    Arduino IDE Configuration (last built with Arduino 1.8.13 + Teensyduino 1.54-beta7):
    Tools/Board: "Teensy 4.1"
    Tools/USB Type: "Serial + MIDI"
    Tools/CPU Speed: "600MHz"
    Tools/Optimize: "Smallest Code"
    Tools/Keyboard Layout: "US English"
    Tools/Port: "COMx Serial+MIDI (Teensy 4.1)"
    Using the RA8875 library provided by Teensyduino

    Wiring:
    PIN D0 = MIDI DIN RX
    PIN D1 = MIDI DOUT TX
    PIN D2 = RA8875 Touchscreen INT
    PIN D3 = RA8875 Touchscreen RESET
    PIN D4 = (not used)
    PIN D5 = (not used)
    PIN D6 = Audio adapter memory chip select
    PIN D7 = Audio adapter data in
    PIN D8 = Audio adapter data out
    PIN D9 = (not used)
    PIN D10 = Audio adapter SD card chip select
    PIN D11 = Audio adapter SPI MOSI (data in)
    PIN D12 = Audio adapter SPI MISO (data out)
    PIN D13 = Audio adapter SPI serial clock + on-board LED
    PIN A0 = (not used)
    PIN A1 = Pot on audio adapter
    PIN A2 = (not used)
    PIN A3 = (not used)
    PIN A4 = (D18) Audio adapter SDA (I2C control data)
    PIN A5 = (D19) Audio adapter SCL (I2C control clock)
    PIN A6 = (not used)
    PIN A7 = (not used)
    PIN A8 = (not used)
    PIN A9 = (not used)
    PIN A10 = (not used)
    PIN A11 = (not used)
    PIN A12 = RA8875 Touchscreen MOSI (MOSI1)
    PIN A13 = RA8875 Touchscreen SCLK (SCK1)
    PIN A14 = RA8875 Touchscreen CS (CS1)
    PIN A15 = RA8875 Touchscreen MISO (MISO1)


    I read thru all of the history in this topic (informative & educational . . . thanks for the customized/optimized library that was produced as a result !!), but I did not find anything that might help solve my current problem without having to specifically ask my question: I previously ordered the RA8875 (TFTM070-05) 800x480 w/ capacitive touch panel & have everything working perfectly with that display & touchpanel. I found the ability to use a finger for the touch to be very convenient, but the (lack of) precision of using a finger tends to make the exact touch point jump around a little, even when incorporating some simple averaging. With this in mind, I thought I'd try the resistive touch panel instead.

    The display portion works equally well on both styles, however, I have not been able to get any of the resistive touch examples to work (I did change the capacitive/resistive selection in the library settings file). Since I am using a separate SPI for the display (to avoid conflict w/ the Audio Adapter), I did have to modify the call to the constructor to accommodate the following alternate pins for each of the examples, but everything else as is:

    Code:
    // when used w/ Audio Adapter, must use an alternate CS pin for the display
    const int RA8875_CHIP_SELECT     = A14;       // Teensy 38 -to- RA8875 05
    const int RA8875_RESET           =   3;       // Teensy 03 -to -RA8875 11
    const int RA8875_MISO            = A15;       // Teensy 39 -to- RA8875 06
    const int RA8875_MOSI            = A12;       // Teensy 26 -to- RA8875 07
    const int RA8875_SCLK            = A13;       // Teensy 27 -to- RA8875 08
    const int RA8875_TS_INT          =   2;       // Teensy 02 -to- RA8875 33
    
    const int RA8875_MAX_TOUCH_LIMIT =   1;
    
    RA8875 tft = RA8875(RA8875_CHIP_SELECT, RA8875_RESET, RA8875_MOSI, RA8875_SCLK, RA8875_MISO);

    In my actual sketch (the updated version of my TeensyMIDIPolySynth), I am using #ifdef to allow switching between the two different touch types as follows (using the call to set the interrupt pin as an example, *after* changing the library settings file to match the particular touchpanel style):

    Code:
    #ifdef USE_RA8875_TOUCH
       tft.useINT(RA8875_TS_INT);   // use generic int helper for Internal Resistive Touch
    #else
       tft.useCapINT(RA8875_TS_INT);   // use the capacitive chip interrupt
    #endif
    So, for my actual question: do I need to do anything special to get the resistive touch panel working, particularly when trying each of the examples ??

    My full sketch is 25000+ lines, so here's a copy of the calibration sketch instead, as modified for my wiring:

    Code:
    /* Simply Touch screen library calibration V2:
     this will help you to calibrate your touch screen by modify
     4 parameters inside RA8875/_utility/RA8875Calibration.h file:
     TOUCSRCAL_XLOW  //min value of x you can get
     TOUCSRCAL_XHIGH  //max value of x you can get
     TOUCSRCAL_YLOW //min value of y you can get
     TOUCSRCAL_YHIGH  //max value of y you can get
     Normally those parameters are set as 0.
      Only for RESISTIVE TOUCH SCREEN!
     It's not a bullet-proof scientist alghorithm but calibrate
     using this method will be fast and enough accurate for basic
     touch screen operations like buttons, etc. If you need more
     precision and you don't want waste resources consider a capacitive touch!
     Now run this program and open Serial Monitor or follow screen instrunctions.
     Works with Arduino 1.0.6 IDE, Arduino 1.6.x IDE
    */
    #include <SPI.h>
    #include <RA8875.h>
    
    /*
    Arduino's
    You are using 4 wire SPI here, so:
     MOSI:  11//DUE refere to arduino site
     MISO:  12//DUE refere to arduino site
     SCK:   13//DUE refere to arduino site
     the rest of pin below:
     */
    
    //#define RA8875_INT 2 //any pin
    //#define RA8875_CS 10 //any digital pin
    //#define RA8875_RESET 9//any pin or nothing!
    //
    //RA8875 tft = RA8875(RA8875_CS,RA8875_RESET);//arduino's
    
    // when used w/ Audio Adapter, must use an alternate CS pin for the display
    const int RA8875_CHIP_SELECT     = A14;       // Teensy 38 -to- RA8875 05
    const int RA8875_RESET           =   3;       // Teensy 03 -to -RA8875 11
    const int RA8875_MISO            = A15;       // Teensy 39 -to- RA8875 06
    const int RA8875_MOSI            = A12;       // Teensy 26 -to- RA8875 07
    const int RA8875_SCLK            = A13;       // Teensy 27 -to- RA8875 08
    const int RA8875_TS_INT          =   2;       // Teensy 02 -to- RA8875 33
    
    const int RA8875_MAX_TOUCH_LIMIT =   1;
    
    RA8875 tft = RA8875(RA8875_CHIP_SELECT, RA8875_RESET, RA8875_MOSI, RA8875_SCLK, RA8875_MISO);
    
    const uint8_t samples = 20;
    uint16_t tempData[samples][2];
    volatile int count = 0;
    uint16_t tx, ty;//used as temp
    uint16_t _XLOW_VAR;
    uint16_t _YLOW_VAR;
    uint16_t _XHIGH_VAR;
    uint16_t _YHIGH_VAR;
    bool proceed;
    int scount = 0;
    
    #if !defined(USE_RA8875_TOUCH) || defined(_AVOID_TOUCHSCREEN)
    #error "you need to enable resistive touchscreen by uncommenting USE_RA8875_TOUCH in settings!"
    #endif
    
    void setup() {
      Serial.begin(38400);
      long unsigned debug_start = millis ();
      while (!Serial && ((millis () - debug_start) <= 5000)) ;
      //  begin display: Choose from: RA8875_480x272, RA8875_800x480, RA8875_800x480ALT, Adafruit_480x272, Adafruit_800x480
      tft.begin(RA8875_800x480);//initialize RA8875
    /* Adafruit_480x272 Adafruit_800x480 RA8875_480x272 RA8875_800x480 */
      tft.useINT(RA8875_TS_INT);//We use generic int helper for Internal Resistive Touch
      tft.touchBegin();//enable touch support for RA8875
      if (tft.touchCalibrated()) {//already calibrated?
        if (tft.width() > 480)  tft.setFontScale(1);
        Serial.println("You have old calibration data present!\n");
        Serial.println("\nPlease open RA8875/_utility/RA8875calibration.h and put zero on the following:\n");
        Serial.println("#define TOUCSRCAL_XLOW  0");
        Serial.println("#define TOUCSRCAL_YLOW  0");
        Serial.println("#define TOUCSRCAL_XHIGH 0");
        Serial.println("#define TOUCSRCAL_YHIGH 0\n");
        Serial.println("Then save and try to run this again!");
        tft.setCursor(0, 0);
        tft.setTextColor(RA8875_RED);
        tft.println("---> You have old calibration data present! <---");
        tft.setTextColor(RA8875_WHITE);
        tft.println("Please open RA8875/_utility/RA8875calibration.h");
        tft.println("and put zero on the following:");
        tft.println(" ");
        tft.println("   #define TOUCSRCAL_XLOW   0");
        tft.println("   #define TOUCSRCAL_YLOW   0");
        tft.println("   #define TOUCSRCAL_XHIGH  0");
        tft.println("   #define TOUCSRCAL_YHIGH  0");
        tft.println(" ");
        tft.print("Then save and try to run this again!");
        proceed = false;
      } else {
        Serial.println("Start calibration, please follow indications...\n");
        Serial.println("\nPlease press FIRMLY the TOP/LEFT angle of your screen now!\n");
        if (tft.width() > 480)  tft.setFontScale(1);
        tft.setCursor(CENTER, CENTER);
        tft.setTextColor(RA8875_WHITE);
        tft.print("Please press the TOP/LEFT angle now!");
        tft.fillCircle(5, 5, 5, RA8875_RED);
        proceed = true;
        //this enable an ISR on CPU and RA8875 INT
        tft.enableISR(true);
        //You can avoid ISR by simple ignore the line above
        //it will use the slower digitalRead(pin) alternative internally
      }
    }
    
    void loop() {
      if (proceed) {
        if (tft.touched()) {
          if (count >= samples) {
            tft.touchEnable(false);
            count = 0;//reset counts
            uint32_t valx = 0;
            uint32_t valy = 0;
    
            if (scount < 1) {
              for (uint8_t i = 0; i < samples; i++) {
                valx += tempData[i][0];
                valy += tempData[i][1];
              }
              valx = valx / samples;
              valy = valy / samples;
              tft.fillWindow();
              if (tft.width() > 480)  tft.setFontScale(1);
              tft.setCursor(CENTER, CENTER);
              tft.setTextColor(RA8875_WHITE);
              tft.println("Top/Left done. Please do not touch screen...");
              tft.setTextColor(RA8875_RED);
              tft.setFontScale(1);
              tft.print("Please do not touch screen!");
              tft.setFontScale(0);
              Serial.print("Top/Left done...");
              Serial.print("Please do not touch screen...");
              _XLOW_VAR = valx;
              _YLOW_VAR = valy;
              delay(3000);
              tft.fillWindow();
              tft.fillCircle(tft.width() - 5, tft.height() - 5, 5, RA8875_RED);
              if (tft.width() > 480)  tft.setFontScale(1);
              tft.setCursor(CENTER, CENTER);
              tft.setTextColor(RA8875_WHITE);
              tft.print("ok, Now Touch Bottom/Right angle!");
              Serial.println("\n...done, Now Touch Bottom/Right angle!");
              delay(2000);
              tft.touchEnable(true);
              scount++;
            } else if (scount >= 1) {
              for (uint8_t i = 0; i < samples; i++) {
                valx += tempData[i][0];
                valy += tempData[i][1];
              }
              valx = valx / samples;
              valy = valy / samples;
              tft.fillWindow();
              tft.setCursor(0, 20);
              tft.setTextColor(RA8875_WHITE);
              tft.println("Calibration done...watch results!");
              Serial.println("\nCalibration done...watch results");
              _XHIGH_VAR = valx;
              _YHIGH_VAR = valy;
              tft.println("Now open file:");
              tft.setTextColor(RA8875_YELLOW);
              tft.println("RA8875/_utility/RA8875Calibration.h");
              tft.setTextColor(RA8875_WHITE);
              Serial.println("\nNow open file RA8875/_utility/RA8875Calibration.h\n");
              Serial.println("Change the following:\n");
              tft.println("Change the following:");
              tft.println(" ");
              tft.setTextColor(RA8875_GREEN);
              tft.print("#define TOUCSRCAL_XLOW   ");
              tft.setTextColor(RA8875_YELLOW);
              tft.println(_XLOW_VAR, DEC);
              tft.setTextColor(RA8875_GREEN);
              tft.print("#define TOUCSRCAL_YLOW   ");
              tft.setTextColor(RA8875_YELLOW);
              tft.println(_YLOW_VAR, DEC);
              tft.setTextColor(RA8875_GREEN);
              tft.print("#define TOUCSRCAL_XHIGH  ");
              tft.setTextColor(RA8875_YELLOW);
              tft.println(_XHIGH_VAR, DEC);
              tft.setTextColor(RA8875_GREEN);
              tft.print("#define TOUCSRCAL_YHIGH  ");
              tft.setTextColor(RA8875_YELLOW);
              tft.println(_YHIGH_VAR, DEC);
              tft.setTextColor(RA8875_WHITE);
              tft.println(" ");
              tft.println("...then save file and you are calibrated!");
              Serial.println("#define TOUCSRCAL_XLOW  0");
              Serial.println("#define TOUCSRCAL_YLOW  0");
              Serial.println("#define TOUCSRCAL_XHIGH 0");
              Serial.println("#define TOUCSRCAL_YHIGH 0");
              Serial.println("\nInto:\n");
              Serial.print("#define TOUCSRCAL_XLOW  ");
              Serial.println(_XLOW_VAR, DEC);
              Serial.print("#define TOUCSRCAL_YLOW  ");
              Serial.println(_YLOW_VAR, DEC);
              Serial.print("#define TOUCSRCAL_XHIGH ");
              Serial.println(_XHIGH_VAR, DEC);
              Serial.print("#define TOUCSRCAL_YHIGH ");
              Serial.println(_YHIGH_VAR, DEC);
              Serial.println("\nSave and Have a nice day!");
              proceed = false;
              tft.touchEnable(false);
            }
          } else {//continue get samples
            delay(1);
            tft.touchReadAdc(&tx, &ty);//we using 10bit adc data here
            if (count >= 0) {
              tempData[count][0] = tx;
              tempData[count][1] = ty;
            }
            count++;
          }
        }
      }//proceed
    }

  21. #296
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    244
    In case anyone in the future stumbles across my earlier question & is having the same problem, the solution to getting the resistive touchscreen to work just like the capacitive touchscreen did for me was very simple: I missed the fact that the interrupt pin for the resistive touchscreen (PIN 10 of 40 on the RA8875) is different from the interrupt pin for the capacitive touchscreen (PIN 33 of 40 on the RA8875) !! I ended up wiring these two pins together at the RA8875 40-pin connector & feeding the combo of the two pins (only one of them is used at a time as I switch between the two types of touchscreens) into D02 on the Teensy 4.1.

    Mark J Culross
    KD5RXT

  22. #297
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    139
    Dear members,
    I have a problem with the awesome fonts, the #include "font_AwesomeF100.h" works perfect however when print some text then still the awesome fonts are actual. See attachment.

    Used T4 and RA8875 display.
    Best regards,
    Johan

    Code:
    #include <SPI.h>
    #include <RA8875.h>
    
    #define RA8875_RESET 255    
    #define RA8875_CS 10
    RA8875 tft = RA8875(RA8875_CS, RA8875_RESET, 11, 13, 12);   // 11=MOSI   13=SCLK   12=MISO  10=CS
    #include "fonts/Liberation_Mono_28.c"
    #include "font_AwesomeF000.h"
    #include "font_AwesomeF200.h"
    #include "font_AwesomeF180.h"
    #include "font_AwesomeF100.h"
    #include "font_AwesomeF080.h"
    void setup() 
    {
     
        tft.begin(RA8875_800x480);
        tft.setFont(AwesomeF100_48);
        tft.setCursor(300,100);
        tft.print(char(18));  // icon
        
        tft.setCursor(300,350);
        tft.setFont(&Liberation_Mono_28); 
        tft.print("Hi");
    }
    void loop() 
    {
    
    }
    Click image for larger version. 

Name:	DeepinScreenshot_select-area_20210327172649.png 
Views:	9 
Size:	329.2 KB 
ID:	24205
    Last edited by pd0lew; 03-27-2021 at 04:27 PM. Reason: forgot photo

  23. #298
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    139
    Dear group,

    The RA8875 can now be used also for the LolinD32(ESP32) and ESP8266 works out of the box it's not a Teensy but people must know.

    Works with the ILI9341 fonts as well I tried to upload the library but I get errors perhaps the file is to big.

    If there is a way to upload the adjusted library please let me know.

    Best,
    Johan
    Last edited by pd0lew; 04-13-2021 at 11:59 AM. Reason: typo

  24. #299
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    139
    Hereby the test sketch, know that the latest ILI9341_fonts-master must be installed.
    Code:
    // test sketch for LolinD32 (ESP32)
    // Johan Holstein @2021
    #include <SPI.h>
    #include <RA8875.h>
    #define RA8875_CS 5
    int i;
    RA8875 tft = RA8875(RA8875_CS);
    
    #include "font_DroidSansMono.h"
    #include "font_AwesomeF000.h"
    #include "font_AwesomeF200.h"
    #include "font_AwesomeF180.h"
    #include "font_AwesomeF100.h"
    #include "font_AwesomeF080.h"
    
    // colors
    #define BackgroundColor   0x0000
    #define TextColor         0xFFFF
    
    char count[1000];
    char old_count[1000];
    uint16_t counter = 0;
    int direction = 1;
    
    void setup() {
      tft.begin(RA8875_800x480);
      tft.setCursor(250, 220);
      tft.setFont(DroidSansMono_96);
      tft.clearMemory();
    
    }
    
    void loop() {
    
      dtostrf(counter, 4, 0, count);
    
      for (int i = 0; i <= 3; i++) {
        if (count[i] != old_count[i]) {
          tft.setCursor(200 + i * 70, 250);
          tft.setTextColor(BackgroundColor);
          tft.print(old_count[i]);
          tft.setCursor(200 + i * 70, 250);
          tft.setTextColor(TextColor);
          tft.print(count[i]);
        }
      }
      counter = counter + direction;
      if (counter == 12000) {
        direction = -1;
      }
      if (counter == 0) {
        direction = 1;
      }
      strncpy(old_count, count, 1000);
    }

Posting Permissions

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