sumotoy / TFT_ILI9163C

A library for ILI9163C displays for Teensy, Arduino, ESP82266 and more...
171 stars 72 forks source link

128x128 red board offset confusion #66

Open ecolyx opened 6 years ago

ecolyx commented 6 years ago

My display didn't work with any of the defined board types/resolutions, so I hacked your code and got it working in each rotation. I split OFFSET into OFFSETX and OFFSETY, as the offset is different in landscape and portrait orientations, and then wrote an address pair for each rotation. The code works, but doesn't make sense to me, and I can't port it to the other boards, so haven't submitted a pull request. This will break the code when other boards are defined.

I would be happy to modify and submit if someone wants to explain how the g.ram is being mapped to the display in this situation, and whether the code can actually be written in a more meaningful manner, and make it compatible with the other pcbs.

I expected to end up with maybe two code section, for horizontal and vertical orientations, but the offsets requried in each rotation that work don't seem to allow for this to happen..

in the .h file

#if defined(__144_RED_PCB__)
...
    #define __OFFSETX       2//*see note 2
    #define __OFFSETY       1//*see note 2

in the .cpp file

void TFT_ILI9163C::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
    #if defined(__MK20DX128__) || defined(__MK20DX256__)
        SPI.beginTransaction(ILI9163C_SPI);
        _setAddrWindow(x0,y0,x1,y1);
        SPI.endTransaction();
    #else
        writecommand(CMD_CLMADRS); // Column
        if (rotation == 0){
            writedata16(x0 + __OFFSETX);
            writedata16(x1);
        } else if (rotation == 1) {
            writedata16(x0 + __OFFSETY);
            writedata16(x1 + __OFFSETY);
        } else if (rotation == 2) {
            writedata16(x0 + __OFFSETX);
            writedata16(x1 + __OFFSETX);
        } else {
            writedata16(x0 + 3);
            writedata16(x1 + 3);
        }

        writecommand(CMD_PGEADRS); // Page
        if (rotation == 0) {
            writedata16(y0 + __OFFSETY);
            writedata16(y1 + __OFFSETY);
        } else if (rotation == 1) {
            writedata16(y0 + __OFFSETX);
            writedata16(y1 + __OFFSETX);
        } else if (rotation == 2) {
            writedata16(y0 + 3);
            writedata16(y1 + 3);
        } else {
            writedata16(y0 + __OFFSETX);
            writedata16(y1 + __OFFSETX);
        }
        writecommand(CMD_RAMWR); //Into RAM
    #endif
}
ecolyx commented 6 years ago

Having studied the datasheet and code, all I can think is that this board has been wired as a 128x162 display by the manufacturer rather than 128x160 of the typical 1.44" red pcbs.

I may experiment with this idea.

SurenBono commented 5 years ago

offset err

SurenBono commented 5 years ago

tft blanked display after init TFT_ILI9163C Pinout

vsbogd commented 5 years ago

It seems, that I have the same issue as @ecolyx, at least I ended up with the same fix as he did.

@SurenBono, making __OFFSET == 0 solves issue with large noised bar at the top of the display as your pictures shows, but after that two artifacts are still there:

SurenBono commented 5 years ago

Than check your width and height dimensions is it 128 x 160..?..or is still defined as 128x 128... this SPI TFT ili9163c is working on wemos d1r1 ..and should be manufactured as a stackable version.. i purchased a stacked version last time but it was 8 bit..incompatible with esp8266 and esp32 ...only ran on uno

On 2:15pm, Fri, Jun 28, 2019 Vitaly Bogdanov <notifications@github.com wrote:

It seems, that I have the same issue as @ecolyx, at least I ended up with the same fix as he did.

@SurenBono, making __OFFSET == 0 solves issue with large noised bar at the top of the display as your pictures shows, but after that two artifacts are still there:

image shifted 2 pixels to the left, and 2 pixels noised vertical lines on the right; noised line ~1 pixel width at the bottom;

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

vsbogd commented 5 years ago

Than check your width and height dimensions is it 128 x 160..?..or is still defined as 128x 128...

Yes, I have checked it, my config is:

    #define _TFTWIDTH       128//the REAL W resolution of the TFT
    #define _TFTHEIGHT      128//the REAL H resolution of the TFT
    #define _GRAMWIDTH      128
    #define _GRAMHEIGH      160
    #define _GRAMSIZE       _GRAMWIDTH * _GRAMHEIGH//*see note 1
    #define __COLORSPC      1// 1:GBR - 0:RGB
    #define __GAMMASET1     //uncomment for another gamma
    #define __OFFSET        0

On the photo below it can be seen that:

  1. Both top and left yellow lines are not visible
  2. Noise points at the right side of the screen

(Sorry for a photo quality, could not get anything better)

screenshot

SurenBono commented 5 years ago

Try a different sketch...the Clock and see if it still persist...or uncomment the black definition instead of red in _setting

       © SROTO&GARGEES™ <https://srotogargees.business.site/> c/o Suren

On Mon, Jul 1, 2019 at 2:40 AM Vitaly Bogdanov notifications@github.com wrote:

Than check your width and height dimensions is it 128 x 160..?..or is still defined as 128x 128...

Yes, I have checked it, my config is:

define _TFTWIDTH 128//the REAL W resolution of the TFT

define _TFTHEIGHT 128//the REAL H resolution of the TFT

define _GRAMWIDTH 128

define _GRAMHEIGH 160

define _GRAMSIZE _GRAMWIDTH _GRAMHEIGH//see note 1

define __COLORSPC 1// 1:GBR - 0:RGB

define __GAMMASET1 //uncomment for another gamma

define __OFFSET 0

On the photo below it can be seen that:

  1. Both top and left yellow lines are not visible
  2. Noise points at the right side of the screen

(Sorry for a photo quality, could not get anything better)

[image: screenshot] https://user-images.githubusercontent.com/983480/60400629-25de7a80-9b7f-11e9-98c6-80f21c2309ba.jpg

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sumotoy/TFT_ILI9163C/issues/66?email_source=notifications&email_token=AK2KU5YDJTRLQNLJFQMWMQ3P5D43BA5CNFSM4E7FLG62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY4RMRI#issuecomment-507057733, or mute the thread https://github.com/notifications/unsubscribe-auth/AK2KU557YBI7FL5PSPF7OR3P5D43BANCNFSM4E7FLG6Q .

ecolyx commented 5 years ago

I assure you I tried all these suggestions before modifying the code with seperate offsets.

Perhaps you could look at what my code changes and why it appears to work for us, when none of the suggested settings do work?

SurenBono commented 5 years ago

Return and refund..mine worked just fine.initialy it had an offset error.later fixed it ..i think the manufacturer messed up on its labelling and everything else such as your issue...cant they make one that is compatible for all board..uno,esp8266 & esp32 uno styled stacked SPI

On 5:57pm, Mon, Jul 1, 2019 Charlie Stott <notifications@github.com wrote:

I assure you I tried all these suggestions before modifying the code with seperate offsets.

Perhaps you could look at what my code changes and why it appears to work for us, when none of the suggested settings do work?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sumotoy/TFT_ILI9163C/issues/66?email_source=notifications&email_token=AK2KU56UNAFPZMX63E4GRXDP5HIKHA5CNFSM4E7FLG62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY5T7LA#issuecomment-507199404, or mute the thread https://github.com/notifications/unsubscribe-auth/AK2KU565CQKGVEFGZP5W7XDP5HIKHANCNFSM4E7FLG6Q .

vsbogd commented 5 years ago

BTW, @SurenBono , which version of TFT_ILI9163C code do you use? Do you use master branch or another one or tag?

SurenBono commented 5 years ago

Sumotoys version....but i purchased it for my version of edzelf esp radio on D1R1 which originally writen for nodemcu..check it out..

On 5:17pm, Thu, Jul 4, 2019 Vitaly Bogdanov <notifications@github.com wrote:

BTW, @SurenBono https://github.com/SurenBono , which version of TFT_ILI9163C code do you use? Do you use master branch or another one or tag?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sumotoy/TFT_ILI9163C/issues/66?email_source=notifications&email_token=AK2KU5YQFANHL5P2BZJIMJTP5W54PA5CNFSM4E7FLG62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZG3GLQ#issuecomment-508408622, or mute the thread https://github.com/notifications/unsubscribe-auth/AK2KU5YSU4SQD6X7Y7LQ433P5W54PANCNFSM4E7FLG6Q .

SurenBono commented 5 years ago

This was the wiring diagram that worked..

On 12:31am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

On 12:28am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

On 12:24am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

Sumotoys version....but i purchased it for my version of edzelf esp radio on D1R1 which originally writen for nodemcu..check it out..

On 5:17pm, Thu, Jul 4, 2019 Vitaly Bogdanov <notifications@github.com wrote:

BTW, @SurenBono https://github.com/SurenBono , which version of TFT_ILI9163C code do you use? Do you use master branch or another one or tag?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sumotoy/TFT_ILI9163C/issues/66?email_source=notifications&email_token=AK2KU5YQFANHL5P2BZJIMJTP5W54PA5CNFSM4E7FLG62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZG3GLQ#issuecomment-508408622, or mute the thread https://github.com/notifications/unsubscribe-auth/AK2KU5YSU4SQD6X7Y7LQ433P5W54PANCNFSM4E7FLG6Q .

SurenBono commented 5 years ago

Finally ..try to define outside the box 130 x 165 mybe its more than the default 128x160 dimension for your display...or count the pixel to check

On 12:38am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

This was the wiring diagram that worked..

On 12:31am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

On 12:28am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

On 12:24am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

Sumotoys version....but i purchased it for my version of edzelf esp radio on D1R1 which originally writen for nodemcu..check it out..

On 5:17pm, Thu, Jul 4, 2019 Vitaly Bogdanov <notifications@github.com wrote:

BTW, @SurenBono https://github.com/SurenBono , which version of TFT_ILI9163C code do you use? Do you use master branch or another one or tag?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sumotoy/TFT_ILI9163C/issues/66?email_source=notifications&email_token=AK2KU5YQFANHL5P2BZJIMJTP5W54PA5CNFSM4E7FLG62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZG3GLQ#issuecomment-508408622, or mute the thread https://github.com/notifications/unsubscribe-auth/AK2KU5YSU4SQD6X7Y7LQ433P5W54PANCNFSM4E7FLG6Q .

SurenBono commented 5 years ago

Or redefine it smaller bypassing the noise spectrum.. example= 127x159 ...etc

On 1:29am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

Finally ..try to define outside the box 130 x 165 mybe its more than the default 128x160 dimension for your display...or count the pixel to check

On 12:38am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

This was the wiring diagram that worked..

On 12:31am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

On 12:28am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

On 12:24am, Sun, Jul 7, 2019 Suren Bono <surenbono76@gmail.com wrote:

Sumotoys version....but i purchased it for my version of edzelf esp radio on D1R1 which originally writen for nodemcu..check it out..

On 5:17pm, Thu, Jul 4, 2019 Vitaly Bogdanov <notifications@github.com wrote:

BTW, @SurenBono https://github.com/SurenBono , which version of TFT_ILI9163C code do you use? Do you use master branch or another one or tag?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sumotoy/TFT_ILI9163C/issues/66?email_source=notifications&email_token=AK2KU5YQFANHL5P2BZJIMJTP5W54PA5CNFSM4E7FLG62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZG3GLQ#issuecomment-508408622, or mute the thread https://github.com/notifications/unsubscribe-auth/AK2KU5YSU4SQD6X7Y7LQ433P5W54PANCNFSM4E7FLG6Q .

vsbogd commented 5 years ago

This configuration makes "fill by rectangles" test looks perfect, but on text test it can be seen that image is still shifted to the right:

    #define _TFTWIDTH       131//the REAL W resolution of the TFT
    #define _TFTHEIGHT      128//the REAL H resolution of the TFT
    #define _GRAMWIDTH      131
    #define _GRAMHEIGH      160
    #define _GRAMSIZE       _GRAMWIDTH * _GRAMHEIGH//*see note 1
    #define __COLORSPC      1// 1:GBR - 0:RGB
    #define __GAMMASET1     //uncomment for another gamma
    #define __OFFSET        1

To be clear this text test looks equally shifted with config above and with config from https://github.com/sumotoy/TFT_ILI9163C/issues/66#issuecomment-507057733

IMG_20190708_092536

SurenBono commented 5 years ago

Ok..great...now start your cursor above zero..if normally set cursor (0,0) then start with example ( 5,5)...or so

On 11:05pm, Mon, Jul 8, 2019 Vitaly Bogdanov <notifications@github.com wrote:

This configuration makes "fill by rectangles" test looks perfect, but on text test it can be seen that image is still shifted to the right:

define _TFTWIDTH 131//the REAL W resolution of the TFT

define _TFTHEIGHT 128//the REAL H resolution of the TFT

define _GRAMWIDTH 131

define _GRAMHEIGH 160

define _GRAMSIZE _GRAMWIDTH _GRAMHEIGH//see note 1

define __COLORSPC 1// 1:GBR - 0:RGB

define __GAMMASET1 //uncomment for another gamma

define __OFFSET 1

To be clear this text test looks equally shifted with config above and with config from #66 (comment)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

SurenBono commented 5 years ago

...those fillbyrectangles are codes for clearscreen for landscape mode which is (3) and portrait as (1)....why not code it in the source library as such that we only need to mention tft.clearscreen for both ..

On 2:58pm, Mon, Jul 1, 2019 Suren Bono <surenbono76@gmail.com wrote:

Try a different sketch...the Clock and see if it still persist...or uncomment the black definition instead of red in _setting

       © SROTO&GARGEES™ <https://srotogargees.business.site/> c/o

Suren

On Mon, Jul 1, 2019 at 2:40 AM Vitaly Bogdanov notifications@github.com wrote:

Than check your width and height dimensions is it 128 x 160..?..or is still defined as 128x 128...

Yes, I have checked it, my config is:

define _TFTWIDTH 128//the REAL W resolution of the TFT

define _TFTHEIGHT 128//the REAL H resolution of the TFT

define _GRAMWIDTH 128

define _GRAMHEIGH 160

define _GRAMSIZE _GRAMWIDTH _GRAMHEIGH//see note 1

define __COLORSPC 1// 1:GBR - 0:RGB

define __GAMMASET1 //uncomment for another gamma

define __OFFSET 0

On the photo below it can be seen that:

  1. Both top and left yellow lines are not visible
  2. Noise points at the right side of the screen

(Sorry for a photo quality, could not get anything better)

[image: screenshot] https://user-images.githubusercontent.com/983480/60400629-25de7a80-9b7f-11e9-98c6-80f21c2309ba.jpg

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sumotoy/TFT_ILI9163C/issues/66?email_source=notifications&email_token=AK2KU5YDJTRLQNLJFQMWMQ3P5D43BA5CNFSM4E7FLG62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY4RMRI#issuecomment-507057733, or mute the thread https://github.com/notifications/unsubscribe-auth/AK2KU557YBI7FL5PSPF7OR3P5D43BANCNFSM4E7FLG6Q .

ecolyx commented 5 years ago

"I would be happy to modify and submit if someone wants to explain how the g.ram is being mapped to the display in this situation"

Would be much easier if someone could respond to this. Then we would not need to reverse engineer by trial and error.

Having worked for ARM Holdings as a core code maintainer, I suggest this should be much easier to solve than following the current methodology

vsbogd commented 5 years ago

Ok..great...now start your cursor above zero..if normally set cursor (0,0) then start with example ( 5,5)...or so

What is the goal of the test? I am 99% sure that I will see normal picture when will start from (2, 1) position.

vsbogd commented 5 years ago

Finally, I have found that my TFT has ST7735 controller not ILI9163C. @ecolyx, probably you also can try https://github.com/adafruit/Adafruit-ST7735-Library instead.

Sorry for confusion, not an issue for me anymore.

ecolyx commented 5 years ago

Oh, thankyou.

Interesting discovery, I will investigate when I get a chance to review this project.

Is there a simple way to identify the controller?

vsbogd commented 5 years ago

Is there a simple way to identify the controller?

Yeah, nice question :-) I see that sometimes it can be deduced by reading device registers, like in https://github.com/prenticedavid/MCUFRIEND_kbv/blob/master/examples/LCD_ID_readreg/LCD_ID_readreg.ino But not sure about general case.

ecolyx commented 5 years ago

Thankyou, I'll investigate :-)

SurenBono commented 5 years ago

Mine is not stm display but the original ili9163c module and its working perfectly .thnks for your concern

On 11:24pm, Sun, Aug 4, 2019 Vitaly Bogdanov <notifications@github.com wrote:

Finally, I have found that my TFT has ST7735 controller not ILI9163C. @ecolyx https://github.com/ecolyx, probably you also can try https://github.com/adafruit/Adafruit-ST7735-Library instead.

Sorry for confusion, not an issue for me anymore.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sumotoy/TFT_ILI9163C/issues/66?email_source=notifications&email_token=AK2KU52DSJDYESMB2ZVTHZDQC3YDXA5CNFSM4E7FLG62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3QD44Q#issuecomment-518012530, or mute the thread https://github.com/notifications/unsubscribe-auth/AK2KU52DDXAXRCU4UPGNZNDQC3YDXANCNFSM4E7FLG6Q .

punund commented 4 years ago

Finally, I have found that my TFT has ST7735 controller not ILI9163C. @ecolyx, probably you also can try https://github.com/adafruit/Adafruit-ST7735-Library instead.

Sorry for confusion, not an issue for me anymore.

Are you sure it's ST7735? I have the same display and the same issue, but it won't work with ST7735 libraries.

ceptimus commented 2 years ago

I have a red board with yellow headers. Works perfectly (whole display filled with no noise on any edges) with Adafruit_ST7735 library. Define the right pins for your connection. I'm using a (3.3V 8MHz) Pro Mini with:

define TFT_CS 10

define TFT_RST 8

define TFT_DC 9

and tft.initR(INITR_144GREENTAB);

note the pin on the board that connects to my Arduino 'D9', is labelled A0, not DC

Text on back says of board says, 1.44' SPI 128*128 V1.1

eletroeduardo commented 1 year ago

Hi!

Just for record, having the same issue as @vsbogd, my solution was:

__OFFSET 32 -> 0 (same as previously stated) in TFT_ILI9163C.cpp's setAddrWindow function, bettwen#else and writecommand, add

x0 += 2;
x1 += 2;
jossueIvan commented 7 months ago

se puede conectar a un esp32 c3 super mini y si si como?