Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 26 to 50 of 53

Thread: In ST7735_t3 : tft.Print and tft.Println do not print spaces

  1. #26
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,099
    did you try using
    Code:
    tft.initR(INITR_MINI160x80)

  2. #27
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,624
    I was going to suggest that one as well as that is the one setup by Adafruit for their mini display...

    Also you might also @UHF you might post a zip file with a copy of your older library that you say works. So that we might compare the two, both to see if maybe you changed something with the earlier library as I believe the Green tab always assumed the 128x128 layout.

    And if the member variable _screenWidth is not correct all bets are off.

    That is the Line function for example calls:
    Code:
    void Pixel(int16_t x, int16_t y, uint16_t color)
    	  __attribute__((always_inline)) {
    	    x+=_originx;
    	    y+=_originy;
    
    	  	//if((x < _displayclipx1) ||(x >= _displayclipx2) || (y < _displayclipy1) || (y >= _displayclipy2)) return;
    
    		#ifdef ENABLE_ST77XX_FRAMEBUFFER
    	  	if (_use_fbtft) {
    	  		_pfbtft[y*_screenWidth + x] = color;
    	  		return;
    	  	}
    	  	#endif
    		setAddr(x, y, x, y);
    		writecommand(ST7735_RAMWR);
    		writedata16(color);
    	}
    
    };
    Does it draw differently if you Don't turn on frame buffer?

  3. #28
    Ok INITR_MINI160x80 works... but blue and red are swapped, which is why I never used it previously. I still have to invertDisplay(true). The business with the tabs is quite hit and miss. Frame buffering makes no difference to the problem by the way.

    Edit: Sorry no, it's not working properly. I'm getting the top half of the screen flashing. I'll have another look tomorrow as it's midnight here.
    Last edited by UHF; 04-13-2020 at 03:05 PM.

  4. #29
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,099
    @UHF
    By default when the display starts it always has a white background. Instead of using invertDisplay(true) just try using:
    Code:
    tft.fillScreen(ST7735_BLACK)
    Inverting the screen colors may be causing you a problem blue and red being swapped.

  5. #30
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,624
    Or when you say colors swapped are you saying that this display has a different order of the 565 colors?

    If we look at the setRotation code we see:
    Code:
         	if ((tabcolor == INITR_BLACKTAB) || (tabcolor == INITR_MINI160x80)) {
    			writedata_last(MADCTL_MX | MADCTL_MY | MADCTL_RGB);
    		} else {
    			writedata_last(MADCTL_MX | MADCTL_MY | MADCTL_BGR);
    		}
    It looks like the Adafruit Mini has RGB but the GREENTAB has BGR...
    Again couple ways to fix.

    a) add some easy way set the color scheme.

    b) Add another color tab define which works for the display....

  6. #31
    Code:
    // This Teensy3 native optimized version requires specific pins
    #define sclk 20  // SCLK can also use pin 14  
    #define mosi 21  // MOSI can also use pin 7
    #define cs  2  // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
    #define dc   3   //but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
    #define rst  8   // RST can use any pin
    
    #include <Adafruit_GFX.h>
    #include <ST7735_t3.h> // Hardware-specific library for T3.x
    #include "Fonts/FreeSansBold18pt7b.h"
    
    ST7735_t3 tft = ST7735_t3(cs, dc, mosi, sclk, rst);
    
    void setup() {
     // tft.useFrameBuffer(true);
    
      tft.initR(INITR_MINI160x80);
      tft.setRotation(3);
      tft.invertDisplay(true);
      tft.fillScreen(ST7735_BLACK);
    
      tft.setFont(&FreeSansBold18pt7b);
      tft.setCursor(53, 10);
      tft.setTextColor(ST7735_YELLOW);
      tft.println("999");
    
      tft.drawLine(20, 50, 20, 80, ST7735_RED);
      tft.drawLine(0, 0, 60, 80, ST7735_BLUE);
      tft.drawLine(20, 50, 60, 50, ST7735_GREEN);
      
    //  tft.updateScreen();
    }
    
    void loop() {
    }
    Using the code above there are the following problems:
    Blue and red pixels swapped (yes the pixel order is evidently different)
    The rows and columns are offset causing random pixel data at the boundaries
    Click image for larger version. 

Name:	20200414_083818.jpg 
Views:	4 
Size:	98.1 KB 
ID:	19690


    Turning frame buffering on is causing the top half of the screen to disappear or sometimes flash:
    Click image for larger version. 

Name:	20200414_083920.jpg 
Views:	2 
Size:	90.7 KB 
ID:	19691




    INITR_GREENTAB in 1.48 worked perfectly (unmodified), even if it was meant for a different resolution. Another initialisation scheme would be good, as anyone not using Adafruit displays are likely using these cheaper ones with semi-random variations. The one I'm using is quite ubiquitous.
    Last edited by UHF; 04-14-2020 at 12:22 AM.

  7. #32
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,099
    A couple of suggestions that you may want to try.

    The tft.initR(INITR_MINI160x80); defaults to the following row and column start positions:
    Code:
    	    _colstart = 24;
    	    _rowstart = 0;
    You can adjust these settings using the tft.setRowColStart(row, column). You can try just setting it 0,0 and try adjusting from there in the setup after initR. Also, comment out the tft.invertDisplay(true) - this is more for my curiosity.
    Code:
    void setup() {
     // tft.useFrameBuffer(true);
    
      tft.initR(INITR_MINI160x80);
      tft.setRowColStart(0,0);  // try tweaking for your display
      tft.setRotation(3);
      //tft.invertDisplay(true);
      tft.fillScreen(ST7735_BLACK);
    I have been running with out framebuffer turned on so can not comment on that - will give it a try with my display.

  8. #33
    Junior Member
    Join Date
    Dec 2019
    Posts
    11
    Are versions of ST7735_t3 archived anywhere on the site for dl? (I did look, but did not find any)

  9. #34
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,099
    Quote Originally Posted by DrGee View Post
    Are versions of ST7735_t3 archived anywhere on the site for dl? (I did look, but did not find any)
    In case no. I just deleted my old repository in favor of using a forked copy of the TD version. @KurtE may have some old version laying around.

    BTW: When I ran the sketch I saw the color issue that you are seeing. I deleted the invertDisplay line and colors printed correctly.

    I can not seem to duplicate the issue with the framebuffer that you are seeing.

  10. #35
    Junior Member
    Join Date
    Dec 2019
    Posts
    11
    Quote Originally Posted by mjs513 View Post
    In case no. I just deleted my old repository in favor of using a forked copy of the TD version. @KurtE may have some old version laying around.

    BTW: When I ran the sketch I saw the color issue that you are seeing. I deleted the invertDisplay line and colors printed correctly.

    I can not seem to duplicate the issue with the framebuffer that you are seeing.

    Not sure you mean me re:color and I was on a Teensy LC which doesn't use frame buffer.

    On a more general note, when I started to mess with these 80x160 dots 0.96" color tft lcds (probably these https://www.buydisplay.com/spi-tft-0...rduino-library) it was very frustrating. I made a valiant attempt (sure doing color defines in the program to account for BGR instead of RGB [although I see I commented them as GBR ] and figuring out CASET and RASET and so on. The way MADCTL parts are defined was cumbersome to me and I couldn't easily find a solution.

    Because I had a specific one-off project that only needed some basics, I was fine kludging it together so that it worked. So when the version changed, I ended up with a big set-back (most annoying because I did not save the versions first, before updating).

    Don't get me wrong, I really am not whining. I read an older thread (here) on this controller and it is a royal pain. For my 2 cents, making new "tab" versions is probably not the way to go. Colored tabs, while meaningful at one time and in one place, might have made sense, I don't think they do now. For example, see https://forum.arduino.cc/index.php?topic=397984.0 with a popular display - he went to a GREENTAB2 setting...what's next - 3,4 and 5 versions of different tab colors?

    Ideally, I suppose that a ST7735_t3 that handled all of the teensy issues well and had a basic template for the myriad of displays that use the ST7735 and facilitated control by the user program would be great. Then, versions supporting various displays could be user-configured. Of course, it's just my 2 cents and I don't even know how many displays that you *should* support - how do you determine that?

    In any event, i do appreciate the efforts that you folks are putting into it.

  11. #36
    Code:
    // This Teensy3 native optimized version requires specific pins
    #define sclk 20  // SCLK can also use pin 14  
    #define mosi 21  // MOSI can also use pin 7
    #define cs  2  // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
    #define dc   3   //but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
    #define rst  8   // RST can use any pin
    
    #include <Adafruit_GFX.h>
    #include <ST7735_t3.h> // Hardware-specific library for T3.x
    #include "Fonts/FreeSansBold18pt7b.h"
    
    ST7735_t3 tft = ST7735_t3(cs, dc, mosi, sclk, rst);
    
    void setup() {
      // tft.useFrameBuffer(true);
    
      tft.initR(INITR_MINI160x80);
      tft.setRowColStart(10, 26); // Row has NO effect whatever you set
      tft.setRotation(3);
      // tft.invertDisplay(true);
      tft.fillScreen(ST7735_BLACK);
    
      tft.setFont(&FreeSansBold18pt7b);
      tft.setCursor(40, 30);
      tft.setTextColor(ST7735_YELLOW);
      tft.println("9 9 9");
    
      tft.drawLine(1, 1, 1, 80, ST7735_RED);//left vertical
      tft.drawLine(160, 1, 160, 80, ST7735_MAGENTA);//right vertical - DOESN'T appear
      tft.drawLine(1, 1, 160, 1, ST7735_BLUE);//top horizontal
      tft.drawLine(1, 80, 160, 80, ST7735_YELLOW);//bottom horizontal - DOESN'T appear
      tft.drawLine(1, 1, 160, 80, ST7735_GREEN);//diagonal across whole screen
    
      //  tft.updateScreen();
    }
    
    void loop() {
    }

    Produces:
    Click image for larger version. 

Name:	notinverted.jpg 
Views:	5 
Size:	206.4 KB 
ID:	19695

    Using invertScreen(true) produces:
    Click image for larger version. 

Name:	inverted.jpg 
Views:	3 
Size:	154.7 KB 
ID:	19696

    Setting row has no effect and the row seems to start from 2 which is why the right vertical line doesn't appear. I think the top horizontal line starts at 1 however.

  12. #37
    Quote Originally Posted by DrGee View Post
    Don't get me wrong, I really am not whining. I read an older thread (here) on this controller and it is a royal pain. For my 2 cents, making new "tab" versions is probably not the way to go. Colored tabs, while meaningful at one time and in one place, might have made sense, I don't think they do now. For example, see https://forum.arduino.cc/index.php?topic=397984.0 with a popular display - he went to a GREENTAB2 setting...what's next - 3,4 and 5 versions of different tab colors?

    In any event, i do appreciate the efforts that you folks are putting into it.
    I agree, tab colours don't work except for Adafruit displays with slightly better controlled supplies.

  13. #38
    My display is a ST7735S by the way, the library only mentions ST7735B and ST7735R screens, hence the INITR initialisers.

  14. #39
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,099
    @UHF
    Thanks for checking with your display on the invertDisplay. On mine when I used the colors changed from what I was requesting thought it might be something simple with your display.

    Interesting on the ST7735S because the Adafruit mini160x80 uses the same controller according to the datasheet: https://learn.adafruit.com/adafruit-...kout/downloads

  15. #40
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,624
    Somewhere around here I think I have an Adafruit one... .96"... But finding which pile/stack/cabinet it got stuffed into...

    At some point will order a different one and see what it does. All of the ones from Amazon, but they all ship from overseas and show estimated delivery 1.5-2 months. May order one from Digikey or BuyDisplay.

  16. #41
    I really don't envy your task, trying to accommodate variations of what often appear to be the same displays. Again, thanks for both your efforts and for frame buffering! That really made a massive difference to the enthusiasm to carry on with my project. I'll use the 1.48 versions of the files in my project folder in the meantime.

  17. #42
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,624
    @UHF - Thanks, Actually this is one of @Paul's libraries that some of us have had some fun trying to add a few features.

    EDIT: I did order one from digikey... Not sure how it will compare https://www.digikey.com/product-deta...778-PIM436-ND/
    Last edited by KurtE; 04-14-2020 at 07:30 PM.

  18. #43
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,624
    Quick FYI -I received an order from Digikey where I purchased a couple of Adafruit ST7789 small displays 240x135 and some funcky supposedly ST7735 .96" 160x80 display.

    So far nothing is working in the pimoroni.com display... Will debug some... Could also simply be DOA.

    Found are ST7789 code did not have support for the smaller display, so added it and did PR back to PAUL:
    https://github.com/PaulStoffregen/ST7735_t3/pull/16

    Now back to other display...

  19. #44
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,624
    Quick update: I think the ST7735S I received from Digikey From pimoroni.com was a dude... Sometimes a few things flash on the screen, most the time not...
    I tried making same changes... Their stuff was setup for RPI to use a Python program. So I got out RPI3... Installed stuff and still nothing.

    So ordered another one (this time from Mouser) as well as the Adafruit .96" ST7735...

    But while I wait, maybe I will try a hammer on it and see if that helps!

  20. #45
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,099
    Hammer might definitely help

    I hooked up my adafruit mini display(160x90) st7735s and it seems to be working. In regard to the sketch in post 36. If I comment out setrowcol and invertdisplay and use:
    Code:
        tft.drawLine(0, 0, 0, 79, ST7735_RED);//left vertical
      tft.drawLine(159, 0, 159, 79, ST7735_MAGENTA);//right vertical - DOESN'T appear
      tft.drawLine(0, 0, 159, 0, ST7735_BLUE);//top horizontal
      tft.drawLine(0, 79, 159, 79, ST7735_YELLOW);//bottom horizontal - DOESN'T appear
      tft.drawLine(0, 0, 159, 79, ST7735_GREEN);//diagonal across whole screen
    it seems to be working,
    Click image for larger version. 

Name:	IMG-0162.jpg 
Views:	1 
Size:	35.0 KB 
ID:	19801 Lettering is actually Yellow. So it must be something with the non-adafruit displays.

  21. #46
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,624
    @mjs513 I looked at their Python version of driver, which they mentioned they started off with Adafruit stuff and mad it compatible with the ST7735S...
    They centered the display pixels in the display memory. So the actual memory is something like 132x162
    So their memory for display starts at (132-80)/2 = 26 and (162-160)/2 = 1...

    The other one I ordered is the adafruit one like you show.

    Also their MADCTL is different for RGB versus BGR of some other displays... Should get here in a few days...

  22. #47
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,624
    Hammer worked (or at least reseating their display cable cleaning connections, reseat into different place on solderless breadboard and wiring up to different T4.x...

    I just pushed up changes to my my branch which still has an active Pull Request to Pauls master for the ST7789 mini display. I added a new logical Tab color which you can see in my version of the example sketch:
    Code:
    // This Teensy3 native optimized version requires specific pins
    #define sclk 13  // SCLK can also use pin 14  
    #define mosi 11  // MOSI can also use pin 7
    #define cs  10  // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
    #define dc   8   //but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
    #define rst  -1   // RST can use any pin
    #define BL_PIN  7
    
    #include <Adafruit_GFX.h>
    #include <ST7735_t3.h> // Hardware-specific library for T3.x
    #include "Fonts/FreeSansBold18pt7b.h"
    
    ST7735_t3 tft = ST7735_t3(cs, dc);
    
    void setup() {
      // tft.useFrameBuffer(true);
      while (!Serial && millis() < 4000) ;
      Serial.begin(115200);
      Serial.println("setup");
    #ifdef BL_PIN
      pinMode(BL_PIN, OUTPUT);
      digitalWriteFast(BL_PIN, LOW);
      delay(100);
      digitalWriteFast(BL_PIN, HIGH);
    #endif
      tft.initR(INITR_MINI160x80_ST7735S);
      //tft.initR(INITR_GREENTAB);
      Serial.println("After INITR");
      tft.setRotation(1);
      tft.fillScreen(ST7735_BLACK);
      Serial.println("After black screen");
      delay(500);
      tft.fillScreen(ST7735_GREEN);
      Serial.println("After green screen");
      delay(500);
      tft.fillScreen(ST7735_RED);
      Serial.println("After RED screen");
      delay(500);
      tft.fillScreen(ST7735_BLUE);
      Serial.println("After BLUE screen");
      delay(500);
      tft.fillScreen(ST7735_BLACK);
      Serial.println("After black screen");
      delay(500);
    
      tft.setFont(&FreeSansBold18pt7b);
      tft.setCursor(40, 30);
      tft.setTextColor(ST7735_YELLOW);
      tft.println("9 9 9");
    
      tft.drawLine(0, 0, 0, 79, ST7735_RED);//left vertical
      tft.drawLine(159, 0, 159, 79, ST7735_MAGENTA);//right vertical - DOESN'T appear
      tft.drawLine(0, 0, 159, 0, ST7735_BLUE);//top horizontal
      tft.drawLine(0, 79, 159, 79, ST7735_YELLOW);//bottom horizontal - DOESN'T appear
      tft.drawLine(0, 0, 159, 79, ST7735_GREEN);//diagonal across whole screen
    
      //  tft.updateScreen();
    }
    
    void loop() {
    }
    Note: I added stuff to flash some different colors, plus fixed the lines to all work as the pixels are 0 indexed so 0-79 and 1-159

    And I now have:
    Click image for larger version. 

Name:	IMG_1107.jpg 
Views:	4 
Size:	131.6 KB 
ID:	19815

  23. #48
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,490
    Good news @KurtE! Have you posted exact part links to the 2? displays you are working on? "Digikey where I purchased a couple of Adafruit ST7789 small displays 240x135 and some funcky supposedly ST7735 .96" 160x80 display."

    That 0.96 looks to be posted: PIM436 digikey.com/product-detail/en/PIM436/1778-PIM436-ND/

    Digikey search 'Adafruit ST7789' brings up 3? Looks to be 1 in stock of one with buttons? And Mouser has more stock - but on two 240x240 display.

  24. #49
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,624
    ST7780 small one by Adafruit: https://www.adafruit.com/product/4383
    I purchased from Digikey as Adafruit is only shipping to essential services and directs you to digikey, but I believe they may be out of them...

    ST7735S small display is the one your link points to. Plus I have another one coming from Mouser.
    https://www.mouser.com/ProductDetail...uvafOMQKvl0%3D

    Since I ordered another from Mouser I also ordered an Adafruit .96" ST7735 display to double check again.
    https://www.mouser.com/ProductDetail...U%252BGfUjs%3D

  25. #50
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,099
    @KurtE
    Nice work on the changes, as @defragster said.

    Just downloaded the updated lib and ran your sketch on the Adafruit ST7735S display. The colors are off using INITR_MINI160x80_ST7735S with the Adafruit display. However, if you use INITR_MINI160x80 it seems to work as it should. Here is the list of colors I see with INITR_MINI160x80_ST7735S:
    White, Magenta, Yellow, Cyan, and back to white.

    Just figured I would let you know. Probably need some warning about that one.

    EDIT: Basically it looks exactly like the image in post #36

Posting Permissions

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