Forum Rule: Always post complete source code & details to reproduce any issue!
Page 10 of 12 FirstFirst ... 8 9 10 11 12 LastLast
Results 226 to 250 of 276

Thread: RA8875 from Buydisplay

  1. #226
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,335
    Hi @mjs513 and all...

    I will have to look more at the software again. What my memory (which may be faulty) remembers reading probably up on WIKI for RA... is something along the line that doing individual sending of bits to the display can be REAL slow. But most operations have hardware accelerator support. I am guessing. Probably the system fonts are already on the display so you simply run a local macro on the display to display them. Likewise probably with their Font chips. I also vaguely remember discussion about how Adafruit display does not support it, but the BuyDisplay may have way to download fonts... But again this is from what I remember from a quick read awhile ago...

    But soon maybe I will have to play some more...

    I have been playing around with Kitchen Sink board for Ra8875, which I may order a set, to see just how bad I screwed it up

    Click image for larger version. 

Name:	RA8875-Round-2.jpg 
Views:	9 
Size:	113.5 KB 
ID:	18618

    I made it the whole size of the 4.3/5" displays... So had to fill the space up with something.
    It is setup to use the FRDM castellated board to get the full T3.6 Form factor, plus hopefully will work when the T4.1 boards come along, and likewise T3.6 like boards...

    Most of the usual junk, like 3 pin headers for lots of the lower pin numbers. Others brought out to bottom as well.
    Two pins have 3.3v -> 5v output Level shifters.
    I added a T3.2 like connections as well so maybe can plug in some of the other boards like Audio...

    Have Audio of two small speakers, plus Adafruit Stereo amp (with I2C configuration) Plus PT8211

    Have 2 Qwiic connectors

    Two 12 bit DACs

    2 LEDS

    2 large pots

    As I said the kitchen sink.

  2. #227
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807
    @KurtE
    Well yes and no. The lib is capable of using external fonts contained in ".c" files. When you are ready here are some links, putting it here now so I don't forget:

    https://github.com/sumotoy/RA8875/wi...convert-a-font
    https://github.com/sumotoy/RA8875/wi...PGO-algorithm)
    https://www.riuson.com/lcd-image-converter/
    https://www.riuson.com/lcd-image-con...examples/fonts

    After reading this going to have to rethink how to use adafruit fonts.

  3. #228
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807

    ILIXXX Fonts and GFX Fonts for RA8875

    Recently @KurtE and I have been working on a modification of the RA8875 library to use the ILI9xxx fonts and Adafruit GFX fonts. We have finished our initial implementation of modifications to the RA8875 library and the ILI9341_font library. Here are some screen shots for the ILI style fonts on the RA8875:
    Click image for larger version. 

Name:	IMG-0076.jpg 
Views:	5 
Size:	97.5 KB 
ID:	18762Click image for larger version. 

Name:	IMG-0077.jpg 
Views:	6 
Size:	103.4 KB 
ID:	18763Click image for larger version. 

Name:	IMG-0078.jpg 
Views:	7 
Size:	108.0 KB 
ID:	18764

    The updated RA8875 library is on the T4 branch: https://github.com/mjs513/RA8875/tree/RA8875_t4
    The fonts are a slightly modified version of the PJRC's ILI9341_fonts library: https://github.com/mjs513/ILI9341_fonts

    Feel free to give it a try.

  4. #229
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,335
    @mjs513 - Looks great!

    A quick FYI to all - Some of this functionality came from the ili9341_t3n and some of the newer stuff was ported back into the ili9341_t3n.
    In particular, it also now supports the GFX fonts as well as the ILI9341_t3 like fonts.

    Also it has been updated to move the font definition into it's own header file and works with @mjs513 version of the font library: https://github.com/mjs513/ILI9341_fonts
    Which has very recently been updated to handle having a display driver like ili9341_t3n or RA8875 having a common font file built in like Arial or Arial bold and have the font library also have it.

    The same test sketch shown in the previous post has been ported over to the ILI9341_t3n library, which only things like color names and names of objects... were changed. Probably some of it should be updated as not everything fits on the screen.
    i.e. the RA8875 has a lot more pixels.

    Click image for larger version. 

Name:	IMG_0139-(002).jpg 
Views:	4 
Size:	54.6 KB 
ID:	18765

  5. #230
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    215
    Quote Originally Posted by mjs513 View Post
    Feel free to give it a try.
    Code:
    void RA8875::setCursor(int16_t x, int16_t y, bool autocenter)
    autocenter does not work anymore. (tested with the internal font)
    Still works fine with the TD1.49 supplied lib.

  6. #231
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807
    Quote Originally Posted by neurofun View Post
    Code:
    void RA8875::setCursor(int16_t x, int16_t y, bool autocenter)
    autocenter does not work anymore. (tested with the internal font)
    Still works fine with the TD1.49 supplied lib.
    Will check it out. Thanks for testing

  7. #232
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    112
    Hi mjs513, Kurt,

    Why you not add the fonts to the RA8875/fonts dir. has that a reason?
    Best,
    Johan

  8. #233
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807
    @neurofun - @KurtE
    Just pushed a fix for autocenter. Let me know if you still have problems. Right now autocenter will only work for default fonts.

  9. #234
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,335
    Quote Originally Posted by pd0lew View Post
    Hi mjs513, Kurt,

    Why you not add the fonts to the RA8875/fonts dir. has that a reason?
    Best,
    Johan
    You can always do that, but suppose you wish to use a different font that is not in the RA8875 library, like all of the ones that Paul has converted and I think Frank may also have a set. Up till now we would have to copy them to the display library we were using, and then edit them as they were referred to by other header file for specific graphic library. Would instead in this case like the ability to have the ILI fonts sort of work like the GFX fonts, where you might have one library with all of them defined and be able to use them across a variety of displays.

    Note: In the case of RA8875 of course you then you have a third case of font types, which are those that were/are setup with this library, by sumatoy

  10. #235
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    215
    Quote Originally Posted by mjs513 View Post
    @neurofun - @KurtE
    Just pushed a fix for autocenter. Let me know if you still have problems. Right now autocenter will only work for default fonts.
    Autocenter is now working for the internal font & the RA8875 lib supplied fonts. Thanks.

  11. #236
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807
    Quote Originally Posted by neurofun View Post
    Autocenter is now working for the internal font & the RA8875 lib supplied fonts. Thanks.
    Thanks to @KurtE, Autocenter is now operational for the ILI9341 and the GFX fonts as well. Enjoy.

  12. #237
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    112
    Thanks guys for the new Library!
    https://www.youtube.com/watch?v=ldhH...ature=youtu.be
    Best,
    Johan

  13. #238
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    112
    Problems with the T4 and the second I2C bus, my RA8875 touchscreen works on 19/18 pins perfect. I use a FT5206 controller, but on pins 16/17 the touchscreen is not working. When I use the scanner it is found with address 0x38 so when using 16/17 but with the test program not. Also used Wire1 and also I puts as a test
    Wire1.setSCL(16);
    Wire1.setSDA(17);

    I am stuck what did I miss.....
    Best,
    Johan

    Code:
    /*
    An example of the internal support for the capacitive touch screen
    that use FT5206.
    Using FT5206 instead resistive RA8875 one give more precision, don't need any calibration
    and you have max 5 concurrent touches plus gesture and more...
    */
    
    #include <SPI.h>
    #include <RA8875.h>
    #include <Wire.h>
    
    
    #define RA8875_CS         10 
    #define RA8875_RESET      255               
    #define RA8875_INT        9
    
    #define MAXTOUCHLIMIT     5//1...5
    
    RA8875 tft = RA8875(RA8875_CS, RA8875_RESET);
    
    
    void setup(){
      /*
      Serial.begin(38400);
      long unsigned debug_start = millis ();
      while (!Serial && ((millis () - debug_start) <= 5000)) ;
      */
     // Wire.setSCL(16);
      //Wire.setSDA(17);
       Wire.begin(0x38);
      tft.begin(RA8875_800x480);
      #if defined(USE_FT5206_TOUCH)
      tft.useCapINT(RA8875_INT);//we use the capacitive chip Interrupt out!
      //the following set the max touches (max 5)
      //it can be placed inside loop but BEFORE touched()
      //to limit dinamically the touches (for example to 1)
      tft.setTouchLimit(MAXTOUCHLIMIT);
      tft.setRotation(0);//this works in any rotation mode!
      tft.enableCapISR(true);//capacitive touch screen interrupt it's armed
      #else
      tft.print("you should open RA8875UserSettings.h file and uncomment USE_FT5206_TOUCH!");
      #endif
      tft.setTextColor(RA8875_WHITE,RA8875_BLACK);
    }
    
    void loop(){
      #if defined(USE_FT5206_TOUCH)
      if (tft.touched()){//if touched(true) detach isr
      //at this point we need to fill the FT5206 registers...
        tft.updateTS();//now we have the data inside library
        tft.setCursor(CENTER,CENTER);
        tft.print("                              ");
        tft.setCursor(CENTER,CENTER);
        tft.print("touches:");
        tft.print(tft.getTouches());
        tft.print(" | gesture:");
        tft.print(tft.getGesture(),HEX);
        tft.print(" | state:");
        tft.print(tft.getTouchState(),HEX);
        //you need to get the coordinates? We need a bidimensional array
        uint16_t coordinates[MAXTOUCHLIMIT][2];//to hold coordinates
        tft.getTScoordinates(coordinates);//done
        //now coordinates has the x,y of all touches
        //now draw something....
        uint16_t tempCol;
        for (uint8_t i=1;i<=tft.getTouches();i++){
          if (i == 1)tempCol = RA8875_RED;
          if (i == 2)tempCol = RA8875_GREEN;
          if (i == 3)tempCol = RA8875_MAGENTA;
          if (i == 4)tempCol = RA8875_CYAN;
          if (i == 5)tempCol = RA8875_YELLOW;
          tft.fillCircle(coordinates[i-1][0],coordinates[i-1][1],10,tempCol);
        }
        tft.enableCapISR();//rearm ISR if needed (touched(true))
        //otherwise it doesn't do nothing...
      }
      #endif
    }
    Last edited by KurtE; 01-22-2020 at 08:04 PM. Reason: code tag

  14. #239
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,335
    The RA8875 code currently does not have any support for any Wire object other than Wire.
    (actually slight lie. on Arduino Due it always uses Wire1).

    The Owner(s) of this library could probably easily add this support

    using something like: Wire.setSDA() and Wire.setSCL() only work for those pins which are specific to the Wire object. i.e. won't convert the Wire object over to Wire1...

    A quick hack you could do, is to edit the library and change every instance of SPI. to SPI1. (except the header file names)...

    I might take a quick look...

  15. #240
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807
    @KurtE
    You beat me to it - just took a look. There's 2 or three places it would have to get changed so you could specify which bus to use. You already identified one. The other is about line 571.

    If the owner's were nice enough it would be great - unfortunately only one of the owners have a capacitive display the other has resistive

  16. #241
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807
    Ok just pushed up a change to my WIP_display_font branch (same as master branch): https://github.com/mjs513/RA8875/tree/WIP-display-fonts that may work.

    In settings at about line 87 you can select the wire bus you want to use:
    Code:
    /* [USE ALTERNATIVE I2C/WIRE ON Teensy's]
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Just uncomment one of the line below, this option works only for Arduino TEENSY and has NO effects
    on other CPU!
    */
    //#define USE_TEENSY_WIRE1_INTERFACE//force use Wire1 (only for DUE, no effects on other CPU)
    //#define USE_TEENSY_WIRE2_INTERFACE//force use Wire2 (only for DUE, no effects on other CPU)
    //#define USE_TEENSY_WIRE3_INTERFACE//force use Wire3 (only for DUE, no effects on other CPU)
    just uncomment one of the lines.

    in RA8875 I added this at about line 34:
    Code:
    		#if defined(___TEENSYES)
    			#if defined(USE_TEENSY_WIRE1_INTERFACE)
    				#define Wire Wire1
    			#elif defined(USE_TEENSY_WIRE2_INTERFACE)
    				#define Wire Wire2
    			#elif defined(USE_TEENSY_WIRE3_INTERFACE)
    				#define Wire Wire3
    			#endif
    		#endif
    May have to change __TEENSYRES to TEENSYDUINO.

    Think this is the easiest way to do it. Let me know if it works or not.

  17. #242
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,335
    @mjs513 and @pd0lew

    I did a quick hack up a new branch and issued a PR back to Mike: https://github.com/KurtE/RA8875/tree/t4_Wire_choose

    setWireObject(&Wire1);

    Which currently needs to be called before the begin method is called.

    Note: may be an issue with Wire, as I may not handle their setting of use Wire1...

    They can always simply call this method. Also not sure if others than Teensy are looking at our fork/branch
    I updated the touch screen example (did not upload this)...
    Code:
    #define RA8875_CS         9 
    #define RA8875_RESET      8                 
    #define RA8875_INT        2
    
    #define MAXTOUCHLIMIT     5//1...5
    
    RA8875 tft = RA8875(RA8875_CS, RA8875_RESET);
    
    
    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.setWireObject(&Wire1);
      tft.begin(RA8875_800x480);
    Tried it on my 4.3" limping along adapter board. Need to finish the other one.

    But I was able to run it using pins 18, 19, then added this call to Set for Wire1 and now works on 17, 16...

    As I mentioned, may be issue for Arduino Due, as they have some mumbo jumbo stuff to say #define Wire Wire1
    Which I probably did not support correctly... Should probably have moved some of the conditional stuff that defined this and simply setup the _wire to be &Wire1 in this case... But not sure if it is worth it?

  18. #243
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,538
    Quote Originally Posted by KurtE View Post
    As I mentioned, may be issue for Arduino Due, as they have some mumbo jumbo stuff to say #define Wire Wire1
    Which I probably did not support correctly... Should probably have moved some of the conditional stuff that defined this and simply setup the _wire to be &Wire1 in this case... But not sure if it is worth it?
    As I recall, the Due (and maybe Mega) were 'unique' in that the I2C interface on the shield was Wire1 instead of Wire. So you see a lot of code that hardwires Wire to be Wire1 on the Due/Mega.

    Yet another 'there is only one interface' that permeates a lot of the library (only one SPI bus, only one Serial port, only one I2C bus, etc.). Yeah, back in the day of the AVR 328p, it made sense. IMHO, it no longer makes sense.

  19. #244

  20. #245
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,335
    @mjs513 - I put in the code for initialize Arduino DUE if that #define is set in the user config, it will initialize wire object to use Wire1.

    Also commented out a Serial.printf in RA8875.cpp file as that won't compile on Arduino DUE..

    Dug out my old DUE and tried wiring up... Nothin... Then looked up DUE wiring and forgot, they don't route SPI to pins 11-13... So printed out chart again, connected up to SPI pins and it works... Note: initialization is a bit flaky... Sometimes I have to unhook DUE plug in reboot and then everything works... Probably some timing issue...

    But I am pretty sure has nothing to do with anything we are changing so...

    Anyway updated GIT... So PR updated. Warning I sort of accidentally uploaded my user config with Capacitive touch enabled and USE_DUE_WIRE1_INTERFACE...

    Tested on Due with and without it. Without it used the Wire object pins With it used the Wire1 pins.

  21. #246
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807
    @KurtE
    Just incorporated the PR. Thanks. 4am here and finally playing catch up

  22. #247

    RA8875 tft.setRotation(1) and (3) problem

    Hello KurtE.
    Thank you very much for
    T4_RA8875_pictureEmbed-190902b.zip
    Example.
    tft.setRotation(2) works perfect, but 1 and 3 not, there is any chance, if possible
    you can take a look at it, and maybe find some solution for it?
    Thank you in advance

  23. #248
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,335
    @momosh13 and maybe @mjs513 and all others...

    Yep the drawImage code in that sketch does not work when in portrait mode.

    Note: I believe that this is and has been an inherent problem with this library, and wish that the owner/developer was still active and could fix it, but...

    I will describe it backwards... For now if you want a crawling version that works in portrait mode, here is a mucked up version of that function.
    Code:
    void drawImage(RA8875writes layer, uint16_t image_width, uint16_t image_height, uint16_t *image, uint16_t bgColor)  {
      // first lets fill in part of screen that our image does not cover
      bool portrait_mode = (tft.getRotation() & 1) ? true : false;
      if (enable_layers) tft.writeTo(layer);
      if ((tft.width() >= image_width) && (tft.height() >= image_height)) {
        uint16_t start_x = (tft.width() - image_width) / 2;
        uint16_t start_y = (tft.height() - image_height) / 2;
    
        tft.fillRect(0, 0, tft.width(), start_y, bgColor);  // top;
        tft.fillRect(0, start_y, start_x, image_height, bgColor); // left
        tft.fillRect(start_x + image_width, start_y, tft.width() - (start_x + image_width), image_height, bgColor); // right
        tft.fillRect(0, start_y + image_height, tft.width(), tft.height() - (start_y + image_height), bgColor); // top;
    
        if (portrait_mode) {
          // see if we can draw one pixel at a time... 
          // to see if that is also busted or only the drawPixels...
          for (uint16_t y = start_y; y < (start_y + image_height); y++) {
            for (uint16_t x = start_x; x < (start_x + image_width); x++) {
              tft.drawPixel(x, y, *image);
              image++;
            }
          }
    
        } else {
          // now lets draw out each of the lines of the image...
          for (uint16_t y = start_y; y < (start_y + image_height); y++) {
            // tft.setY(y); // Not needed drawPixels calls setXY which will set y...
            tft.drawPixels(image, image_width, start_x, y);
            image += image_width;
          }
        }
      } else {
        // We need to rotate the image...
        uint16_t start_y = (tft.height() - image_width) / 2;
        uint16_t start_x = (tft.width() - image_height) / 2;
        //Serial.printf("Rotated: start(%d, %d)\n", start_x, start_y);
        tft.fillRect(0, 0, tft.width(), start_y, bgColor);  // top;
        tft.fillRect(0, start_y, start_x, image_width, bgColor); // left
        tft.fillRect(start_x + image_height, start_y, tft.width() - (start_x + image_height), image_width, bgColor); // right
        tft.fillRect(0, start_y + image_width, tft.width(), tft.height() - (start_y + image_width), bgColor); // top;
    
        // now lets draw out each of the lines of the image...
        static uint16_t rotated_row[800]; // max size.
        // BUGBUG: need to start at end of row and work back or image inverted
        image += (image_width - 1);
        for (uint16_t y = start_y; y < (start_y + image_width); y++) {
          uint16_t *pimage = image;
          for (uint16_t i = 0; i < image_height; i++) {
            rotated_row[i] = *pimage;
            pimage += image_width;
          }
          //Serial.printf("DP %x, %d, %d %d\n", rotated_row, image_height, start_x, y);
          tft.drawPixels(rotated_row, image_height, start_x, y);
          image--;
        }
      }
      if (enable_layers)tft.layerEffect((layer == L1) ? LAYER1 : LAYER2);
    }
    Note, I only hacked it for the case where the image will fit and not be rotated...

    Now to describe the issue with portrait mode and the function drawPixels (as well as several others in the library).
    Code:
    void RA8875::drawPixels(uint16_t p[], uint16_t count, int16_t x, int16_t y)
    {
        //setXY(x,y);
    	uint16_t temp = 0;
    	uint16_t i;
    	if (_textMode) _setTextMode(false);//we are in text mode?
    	setXY(x,y);
        writeCommand(RA8875_MRWC);
        _startSend();
    	//set data
    			_pspi->transfer(RA8875_DATAWRITE);
    	//the loop
    	for (i=0;i<count;i++){
    		if (_color_bpp < 16) {
    			temp = _color16To8bpp(p[i]);//TOTEST:layer bug workaround for 8bit color!
    		} else {
    			temp = p[i];
    		}
    			if (_color_bpp > 8){
    				_pspi->transfer16(temp);
    			} else {//TOTEST:layer bug workaround for 8bit color!
    				_pspi->transfer(temp & 0xFF);
    			}
        }
        _endSend();
    }
    Hopefully I edited out all of the #if stuff to get down to actual code on T4 (or t3.x)

    The issue is that when you are in portrait mode the display really does not know that (I think), but instead when you do things like setXY(x, y), these functions swap what actual registers they set... Note setXY simply call setX and setY
    Code:
    void RA8875::setX(int16_t x) 
    {
    	if (x < 0) x = 0;
    	if (_portrait){//fix 0.69b21
    		if (x >= RA8875_HEIGHT) x = RA8875_HEIGHT-1;
    		_writeRegister(RA8875_CURV0, x & 0xFF);
    		_writeRegister(RA8875_CURV0+1, x >> 8);
    	} else {
    		if (x >= RA8875_WIDTH) x = RA8875_WIDTH-1;
    		_writeRegister(RA8875_CURH0, x & 0xFF);
    		_writeRegister(RA8875_CURH0+1, (x >> 8)); 
    	}
    }
    
    void RA8875::setY(int16_t y) 
    {
    	if (y < 0) y = 0;
    	if (_portrait){//fix 0.69b21
    		if (y >= RA8875_WIDTH) y = RA8875_WIDTH-1;
    		_writeRegister(RA8875_CURH0, y & 0xFF);
    		_writeRegister(RA8875_CURH0+1, (y >> 8)); 
    	} else {
    		if (y >= RA8875_HEIGHT) y = RA8875_HEIGHT-1;
    		_writeRegister(RA8875_CURV0, y & 0xFF);
    		_writeRegister(RA8875_CURV0+1, y >> 8);
    	}
    }
    Then the drawPixels code simply says we will write data to memory. Not sure about the DATAWRITE function, it probably says multiple ones coming. The problem is that in portrait mode it simply starts storing data probably like it is still in landscape mode, that is instead of putting next pixel in the logical X direction it stores it in the logical Y direction...

    So not really sure best way to fix. That is I can imagine and maybe try updating my hacked up (of @Frank B's ) sketch here to maybe try calling drawPixels, with extracting data, like it is rotated, and swapping to update Y instead of x... And see if we get something. But I am not sure if that is the expected way to work with this display/library?

  24. #249
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,335
    Forgot to mention how slow the current work around is, portrait mode:
    Code:
    OMUXC_GPR_GPR17:aaaaaaaf IOMUXC_GPR_GPR16:7 IOMUXC_GPR_GPR14:aa0000
    Initial Stack pointer: 20070000
    ITCM allocated: 65536  DTCM allocated: 458752
    ITCM init range: 0 - b9e0 Count: 47584
    DTCM init range: 20000000 - 200019d0 Count: 6608
    DTCM cleared range: 200019d0 - 200042c0 Count: 10480
    CS:9 RST:8, MOSI:11 SCLK:13 MISO:12
    Screen Width:480 Height: 800
    RA8875_BLACK: 0 0
    RA8875_WHITE: ffff ff
    RA8875_RED: f800 e0
    RA8875_GREEN: 7e0 1c
    RA8875_BLUE: 1f 3
    RA8875_CYAN: 7ff 1f
    RA8875_YELLOW: ffe0 fc
    RA8875_PINK: fcff f3
    RA8875_GRAYSCALE: 841 0
    Display Front of card 1145
    
    Display Back of card 1146
    
    Display front of chip (DMAMEM?) 1146
    
    Display TallDog T4 Card 1616
    Versus rotation 0
    Code:
    IOMUXC_GPR_GPR17:aaaaaaaf IOMUXC_GPR_GPR16:7 IOMUXC_GPR_GPR14:aa0000
    Initial Stack pointer: 20070000
    ITCM allocated: 65536  DTCM allocated: 458752
    ITCM init range: 0 - b9e0 Count: 47584
    DTCM init range: 20000000 - 200019d0 Count: 6608
    DTCM cleared range: 200019d0 - 200042c0 Count: 10480
    CS:9 RST:8, MOSI:11 SCLK:13 MISO:12
    Screen Width:800 Height: 480
    RA8875_BLACK: 0 0
    RA8875_WHITE: ffff ff
    RA8875_RED: f800 e0
    RA8875_GREEN: 7e0 1c
    RA8875_BLUE: 1f 3
    RA8875_CYAN: 7ff 1f
    RA8875_YELLOW: ffe0 fc
    RA8875_PINK: fcff f3
    RA8875_GRAYSCALE: 841 0
    Display Front of card 108
    
    Display Back of card 108
    
    Display front of chip (DMAMEM?) 108

  25. #250
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,335
    Update: I hacked up the code to understand how RA8875 writing to memory works... and have a version of the drawImage that works in portrait mode. But so far only in the case where the image will fit unrotated...
    Code:
    void drawImage(RA8875writes layer, uint16_t image_width, uint16_t image_height, uint16_t *image, uint16_t bgColor)  {
      // first lets fill in part of screen that our image does not cover
      static uint16_t rotated_row[800]; // max size.
      bool portrait_mode = (tft.getRotation() & 1) ? true : false;
      if (enable_layers) tft.writeTo(layer);
      if ((tft.width() >= image_width) && (tft.height() >= image_height)) {
        uint16_t start_x = (tft.width() - image_width) / 2;
        uint16_t start_y = (tft.height() - image_height) / 2;
    
        tft.fillRect(0, 0, tft.width(), start_y, bgColor);  // top;
        tft.fillRect(0, start_y, start_x, image_height, bgColor); // left
        tft.fillRect(start_x + image_width, start_y, tft.width() - (start_x + image_width), image_height, bgColor); // right
        tft.fillRect(0, start_y + image_height, tft.width(), tft.height() - (start_y + image_height), bgColor); // top;
    
        if (portrait_mode) {
          image += (image_width - 1);
          //for (uint16_t x = start_x; x < (start_x + image_width); x++) {
          for (uint16_t x = start_x + image_width -1; x >= start_x; x--) {
            uint16_t *pimage = image;
            for (uint16_t i = 0; i < image_height; i++) {
              rotated_row[i] = *pimage;
              pimage += image_width;
            }
            //Serial.printf("DP %x, %d, %d %d\n", rotated_row, image_height, start_x, y);
            tft.drawPixels(rotated_row, image_height, x, start_y);
            image--;
          }
        } else {
          // now lets draw out each of the lines of the image...
          for (uint16_t y = start_y; y < (start_y + image_height); y++) {
            // tft.setY(y); // Not needed drawPixels calls setXY which will set y...
            tft.drawPixels(image, image_width, start_x, y);
            image += image_width;
          }
        }
      } else {
        // We need to rotate the image...
        uint16_t start_y = (tft.height() - image_width) / 2;
        uint16_t start_x = (tft.width() - image_height) / 2;
        //Serial.printf("Rotated: start(%d, %d)\n", start_x, start_y);
        tft.fillRect(0, 0, tft.width(), start_y, bgColor);  // top;
        tft.fillRect(0, start_y, start_x, image_width, bgColor); // left
        tft.fillRect(start_x + image_height, start_y, tft.width() - (start_x + image_height), image_width, bgColor); // right
        tft.fillRect(0, start_y + image_width, tft.width(), tft.height() - (start_y + image_width), bgColor); // top;
    
        // now lets draw out each of the lines of the image...
        // BUGBUG: need to start at end of row and work back or image inverted
        image += (image_width - 1);
        for (uint16_t y = start_y; y < (start_y + image_width); y++) {
          uint16_t *pimage = image;
          for (uint16_t i = 0; i < image_height; i++) {
            rotated_row[i] = *pimage;
            pimage += image_width;
          }
          //Serial.printf("DP %x, %d, %d %d\n", rotated_row, image_height, start_x, y);
          tft.drawPixels(rotated_row, image_height, start_x, y);
          image--;
        }
      }
      if (enable_layers)tft.layerEffect((layer == L1) ? LAYER1 : LAYER2);
    }
    The code in red shows it. Note I did move an internal array up to make use of it here as well...

    But the good news is, this is reasonably faster than my previous post:
    Code:
    IOMUXC_GPR_GPR17:aaaaaaaf IOMUXC_GPR_GPR16:7 IOMUXC_GPR_GPR14:aa0000
    Initial Stack pointer: 20070000
    ITCM allocated: 65536  DTCM allocated: 458752
    ITCM init range: 0 - b9e0 Count: 47584
    DTCM init range: 20000000 - 200019d0 Count: 6608
    DTCM cleared range: 200019d0 - 200042c0 Count: 10480
    CS:9 RST:8, MOSI:11 SCLK:13 MISO:12
    Screen Width:480 Height: 800
    RA8875_BLACK: 0 0
    RA8875_WHITE: ffff ff
    RA8875_RED: f800 e0
    RA8875_GREEN: 7e0 1c
    RA8875_BLUE: 1f 3
    RA8875_CYAN: 7ff 1f
    RA8875_YELLOW: ffe0 fc
    RA8875_PINK: fcff f3
    RA8875_GRAYSCALE: 841 0
    Display Front of card 136
    Display Back of card 137
    Display front of chip (DMAMEM?) 137
    Display TallDog T4 Card 197
    Display Front of card 136
    Display Back of card 137

Posting Permissions

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