Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

128x128 red board offset confusion #66

Open
ecolyx opened this issue May 10, 2018 · 28 comments
Open

128x128 red board offset confusion #66

ecolyx opened this issue May 10, 2018 · 28 comments

Comments

@ecolyx
Copy link

ecolyx commented May 10, 2018

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
Copy link
Author

ecolyx commented May 10, 2018

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
Copy link

offset err

@SurenBono
Copy link

tft blanked display after init
TFT_ILI9163C Pinout

@vsbogd
Copy link

vsbogd commented Jun 28, 2019

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;

@SurenBono
Copy link

SurenBono commented Jun 29, 2019 via email

@vsbogd
Copy link

vsbogd commented Jun 30, 2019

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
Copy link

SurenBono commented Jul 1, 2019 via email

@ecolyx
Copy link
Author

ecolyx commented Jul 1, 2019

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
Copy link

SurenBono commented Jul 4, 2019 via email

@vsbogd
Copy link

vsbogd commented Jul 4, 2019

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

@SurenBono
Copy link

SurenBono commented Jul 6, 2019 via email

@SurenBono
Copy link

SurenBono commented Jul 6, 2019 via email

@SurenBono
Copy link

SurenBono commented Jul 6, 2019 via email

@SurenBono
Copy link

SurenBono commented Jul 6, 2019 via email

@vsbogd
Copy link

vsbogd commented Jul 8, 2019

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)

IMG_20190708_092536

@SurenBono
Copy link

SurenBono commented Jul 8, 2019 via email

@SurenBono
Copy link

SurenBono commented Jul 8, 2019 via email

@ecolyx
Copy link
Author

ecolyx commented Jul 9, 2019

"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
Copy link

vsbogd commented Jul 9, 2019

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
Copy link

vsbogd commented Aug 4, 2019

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
Copy link
Author

ecolyx commented Aug 4, 2019

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
Copy link

vsbogd commented Aug 5, 2019

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
Copy link
Author

ecolyx commented Aug 5, 2019

Thankyou, I'll investigate :-)

@SurenBono
Copy link

SurenBono commented Aug 6, 2019 via email

@punund
Copy link

punund commented Jun 8, 2020

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
Copy link

ceptimus commented Jul 25, 2022

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
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants