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

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?
 
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:
@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.
 
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....
 
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
20200414_083818.jpg


Turning frame buffering on is causing the top half of the screen to disappear or sometimes flash:
20200414_083920.jpg




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:
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.
 
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.
 
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-...module-160x80-ips-st7735-with-arduino-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.
 
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:
notinverted.jpg

Using invertScreen(true) produces:
inverted.jpg

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.
 
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.
 
My display is a ST7735S by the way, the library only mentions ST7735B and ST7735R screens, hence the INITR initialisers.
 
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.
 
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.
 
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...
 
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! :D
 
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,
IMG-0162.jpg Lettering is actually Yellow. So it must be something with the non-adafruit displays.
 
@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...
 
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:
IMG_1107.jpg
 
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.
 
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/Pimoroni/PIM436?qs=/ha2pyFaduie9D0CDsdF1Mo7njdJoB86uvafOMQKvl0=

Since I ordered another from Mouser I also ordered an Adafruit .96" ST7735 display to double check again.
https://www.mouser.com/ProductDetai...EpiMZZMve4/bfQkoj%2BKBEN5Am0AUKGYXOU%2BGfUjs=
 
@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
 
Back
Top