Go Down

Topic: New library for ST7735 displays and the "Minions" TFT on eBay (Read 14552 times) previous topic - next topic


Wow!  I actually didn't expect anyone would respond to this, being an old thread, and my being satisfied with a half-baked workaround.  But it looks like there is an easy correct fix, but unfortunately I have to press for some kindergarten-level hand-holding to be able to follow your advice(s).  Here's where I am:
  • I have the Qianson 1.8" SPI TFT Display, and it's apparently working, except for initializing offset when using ST7735_BLACK option.  I don't see a GREENTAB2 option in graphicstest sketch, or the Adafruit_ST7735.cpp file.
  • I did discover by using BLACKTAB option in sketch, and in Adafruit_ST7735.cpp, adding colstart = 2, and rowstart = 1 in the initialization procedure for option BLACKTAB, everything worked, including colors.  But I don't think I should be altering formal library code. Here's the code, see very bottom.
Code: [Select]

// Initialization for ST7735R screens (green or red tabs)
void Adafruit_ST7735::initR(uint8_t options) {
  if(options == INITR_GREENTAB) {
    colstart = 2;
    rowstart = 1;
  } else if(options == INITR_144GREENTAB) {
    _height = ST7735_TFTHEIGHT_128;
    _width = ST7735_TFTWIDTH_128;
    colstart = 2;
    rowstart = 3;
  } else if(options == INITR_MINI160x80) {
    _height = ST7735_TFTHEIGHT_160;
    _width = ST7735_TFTWIDTH_80;
    colstart = 24;
    rowstart = 0;
  } else {
    // colstart, rowstart left at default '0' values

  // if black, change MADCTL color filter
  if ((options == INITR_BLACKTAB) || (options == INITR_MINI160x80)) {
    colstart = 2; // #*001 This row added to correct screenfill offset  <== These two lines
    rowstart = 1; // #*001 This row added to correct screenfill offset <==

  • Now regarding your input, I'm sorry, but I couldn't find a User_Config.h file. Should that exist, or do I create one?  If so, I'll need info on how to use it.
  • I have no clue about a mfr panel register - but it looked like that was not your favorite thing, anyway
  • I saw a lot of references to MADCTL in the .cpp file. Again, it's unfamiliar to me, so I'm not clear on what it means to set BGR bit to 0x36. I took a guess and changed the #define MADCTL_BGR 0x08 to 0x36.  That didn't work.  If there's something to read on it, I'll be glad to do my part

I'm sure this is going to be pretty straight-forward, and I thank you for your elp.


The assumption was you were using the library linked to in post #1 of this thread, which is here. That library has it's own examples.

You do not need  the Adafruit libraries and it is unlikely you will get the display you have working with them unless you understand the control register settings.


Oops! My bad.  I jumped in to the tail end of the thread, and, being new, assumed this Adafruit library was just what people used.

I have torn down my breadboard to pursue the wifi function of my project, so am answering without having actually tried your recommended lib.  But, I see what you're saying, and will install and try that lib when I get back to the display part.

Thanks so much,


Hi Bodmer! I have this "clock with thermometer using DS3231 on 1.8" ST7735 display"(https://www.youtube.com/watch?v=aGMP7Hf5hLo), taken from an example of yours here: https://github.com/Bodmer/ TFT_ST7735 and adapted by 'Nicu FLORICA' here: https://github.com/tehniq3/ST7735-display/blob/master/TFT_DigitalClock_RTC.ino and I would like to use it in a display tft 2.2" ili9341; therefore, what should be changed in the code?
I do not have enough knowledge for this, so I ask for your help;
My early thanks


Apr 27, 2018, 12:51 am Last Edit: Apr 27, 2018, 12:52 am by david_prentice
The 132x162 ST7735 and the 240x320 ILI9341 are both MIPI-compliant controllers.

Although the tft.begin() sequence will be different for each controller the general purpose graphics work exactly the same.  i.e. you just #include the relevant library header file and call the constructor.

So if you draw a line or fill a circle,   you give the same instructions to the library and the library gives the same commands to the controller.

Ok,  you might want to increase the size of the geometry on the bigger display.

If you look at Bodmer's TFT_eSPI library for Expressif MCUs,   you just change the target controller in the User_Setup.h file.



Hi David, I was happy to receive your reply!
Due to my inexperience, I ask you: what should I change in the code here:
At line 34 #include, should I replace <TFT_ST7735.h> with <TFT_ILI9341.h>?
And in the sequence, lines 37, 72, 74, etc., should also be changed?
Sorry, like I said, I'm inexperienced in that!
Thanks ++


Apr 27, 2018, 09:09 am Last Edit: Apr 27, 2018, 09:18 am by david_prentice
First off.   Please use the link icon (12th from left) when pasting a URL.
It means that readers can use a Tablet or mobile device.

There are several changes at first glance e.g.
Code: [Select]

//#include <TFT_ST7735.h> // Graphics and font library for ST7735 driver chip
#include <TFT_ILI9341.h> // Graphics and font library for DIFFERENT driver chip
#include <SPI.h>

//TFT_ST7735 tft = TFT_ST7735();  // Invoke library, pins defined in User_Setup.h
TFT_ILI9341 tft = TFT_ILI9341();  // DIFFERENT class constructor, pins defined in User_Setup.h
// see User_Setup.h: RST --> D7, CS --> D9, D/C --> D8, DIN --> D11, CLK --> D13

The beauty of C++ is that you have now got a completely different object called tft.
It is a different class but the methods have the same names and behave the same way.

Subsequent colours are named specifically.   This is crazy.   Rename to universal names e.g. TFT_xxx
Code: [Select]

//  tft.setTextColor(ST7735_YELLOW, ST7735_BLACK); // Note: the new fonts do not draw the background colour
  tft.setTextColor(TFT_YELLOW, TFT_BLACK); // Note: the new fonts do not draw the background colour

Untested.   The screen geometry is different.   You might want to change some dimensions.

Oh.   Thankyou for a well constructed question.   I hope that I have answered ok.
Ask if you are unsure.    It really helps to quote line numbers and references.

Note that most Red ST7735, Red ILI9341 boards expect 3.3V logic signals.    Bodmer gives advice on how to provide 3.3V signals from a 5V Uno or Mega.
Life is simpler with a proper 3.3V Zero, Due, ...



Hi bodmer,

thank you for that fantastic, fast library.

Is there a simple way to detect if the display is connected or not?

Is there a bit more detailed version of the keywords.txt where i can see the expected parameters?



Hi bodmer,
recently I bought such an 1.77 inch display (this one).

Started with the Adafruit libraries, then switched to your library - I'm really pleased with that!
Well - both solutions show random Pixels on two sides of the screen. You included a solution for "green tab" devices, but mine is "red tab".

I had a look into the files and solved the issue by adding a INITR_REDTAB2 more or less similar to the other ones, but without really knowing what I'm exactly doing. Since I'm not on GitHub I would like to suggest the following changes  (current version - downloaded master some days ago):

UserSetup.h - additional line 12:
Code: [Select]

TFT_ST7735.h - additional line 22:
Code: [Select]
#define INITR_REDTAB2   0x4 // Use if you get random pixels on two edges of red tab display

TFT_ST7735.h - additional lines behind 393 (in between REDTAB and BLACKTAB parts):
Code: [Select]
       else if (tabcolor == INITR_REDTAB2)

Edit: This is not sufficient (I checked with GREENTAB2 first without powering off).
It is necessary to do the coordinate shift also, but these need to be adjusted when rotating the display. I'm using setRotate(1) - then these values work:
Code: [Select]

         colstart = 1;
         rowstart = 2;

Need to dig deeper inside :) before making suggestions, but this might help someone using the same Display and this library.

Best regards,


I used the ST7735 lib before 3 months and wrote some  sketches . ( all worked fine )
Today I tried the sketches again and received the following fealures .
I downloaded the new ST7735.lib from GIT but still the same problem .
Do someone can help me with this

Thanks  for France


Arduino: 1.8.7 (Windows 10), Board:"Arduino/Genuino Uno"

C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST7789.cpp: In member function 'virtual void Adafruit_ST7789::setRotation(uint8_t)':

C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST7789.cpp:76:6: error: '_xstart' was not declared in this scope

      _xstart = _colstart;


C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST7789.cpp:77:6: error: '_ystart' was not declared in this scope

      _ystart = _rowstart;


C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST7735.cpp: In member function 'virtual void Adafruit_ST7735::setRotation(uint8_t)':

C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST7735.cpp:248:6: error: '_xstart' was not declared in this scope

      _xstart = _colstart;


C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST7735.cpp:249:6: error: '_ystart' was not declared in this scope

      _ystart = _rowstart;


C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST77xx.cpp: In member function 'virtual void Adafruit_ST77xx::begin(uint32_t)':

C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST77xx.cpp:110:3: error: 'invertOnCommand' was not declared in this scope

   invertOnCommand = ST77XX_INVON;


C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST77xx.cpp:111:3: error: 'invertOffCommand' was not declared in this scope

   invertOffCommand = ST77XX_INVOFF;


C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST77xx.cpp: In member function 'virtual void Adafruit_ST77xx::setAddrWindow(uint16_t, uint16_t, uint16_t, uint16_t)':

C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST77xx.cpp:140:8: error: '_xstart' was not declared in this scope

   x += _xstart;


C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST77xx.cpp:141:8: error: '_ystart' was not declared in this scope

   y += _ystart;


C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST77xx.cpp: In member function 'virtual void Adafruit_ST77xx::setRotation(uint8_t)':

C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST77xx.cpp:170:6: error: '_xstart' was not declared in this scope

      _xstart = _colstart;


C:\Users\f8voa\Documents\Arduino\libraries\Adafruit-ST7735-Library-master\Adafruit_ST77xx.cpp:171:6: error: '_ystart' was not declared in this scope

      _ystart = _rowstart;


exit status 1
Fout bij het compileren voor board Arduino/Genuino Uno

Dit rapport zou meer informatie bevatten met
"Uitgebreide uitvoer weergeven tijden compilatie"
optie aan in Bestand -> Voorkeuren.


There used to be "Adafruit_ST7735" library.
It has been superseded by "Adafruit ST7735 and ST7789 Library"

I suggest that you delete the previous "Adafruit_ST7735" directory if you install the new library.

I have IDE v1.8.1 on this PC.   All the examples seem to compile and run on a ST7735 display without error.
Of course the miniTFTWing sketches require a TFTWing.   The TFTShield18 sketches require a TFTShield18

I don't have a SPI ST7789.  So I have not tested the equivalent sketches.

The new library works out of the box with AVR, Zero, Due, ESP8266, M0 Feather, ...
The "older" library would require some tweaks for different target architectures.

If you have a build problem,  please quote which example sketch.    (with library version, IDE version, Arduino target board)



I have just made my first steps with a 80x160 ST7735 display and I got the examples from the library running. So, thanks a lot! I was thinking about a project where two of these displays are functioning as eyes of an animatronic. Is it possible with this library to connect two (or even more) of these displays to a single Arduino (Pro Mini, Nano, or Uno)?


It is possible to connect two displays but you need to take control of the chip select lines in the sketch and initialise both displays. The performance will of course be halved.

If you want to write exactly the same graphics to both screens the just wire the second display to the same pins as the first. The displays are only ever written to during the init and display updates so the two displays can use the same lines in this case.


It is possible to connect two displays but you need to take control of the chip select lines in the sketch and initialise both displays. The performance will of course be halved.

If you want to write exactly the same graphics to both screens the just wire the second display to the same pins as the first. The displays are only ever written to during the init and display updates so the two displays can use the same lines in this case.
Thank you for the fast reply!
The second point is good news - this will work well for the eyes.
But assuming I would want to add a third display for a mouth, I would have to use the first solution: controlling the chip select lines "by hand". After a quick look in your library, I see that chip select is used in many places (TFT_CS_L and TFT_CS_H, right?). So it is probably not as simple as just setting the respective CS pin to Low (before an init or display update) and High (afterwards)?


To disable te control of the CS line you might be able to set the pin number to minus one:

#define TFT_CS -1

however i am not sure if this is acceptable to the fastpin library which is used to make the library faster.  An alternative is to set it to an unused pin, then connect the display CS lines to other pins controlled from the sketch.

Another way to stop the library controlling the CS line is to comment out the pin control macro in the TFT_ST7735.h file at line 80 and 82 thus:
#define TFT_CS_L   // FastPin<TFT_CS>::lo()
#define TFT_CS_H   // FastPin<TFT_CS>::hi()

Personally I would use a separate pro mini board connected to each display and then use the "mouth board" as the master to command the two eye boards, perhaps via an I2C bus. This is the "distributed prcessing" approach that removes the interdependencies and will simplify each sketch. Then you will not get all the performance limitations having an impact on the graphics timings.

Go Up