Warning: narrowing conversion from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

Hi,

I'm working on "LCDWIKI_SPI" library for ST7796S TFT 4" display. It compiles and working.

But I'm getting this warning:

void LCDWIKI_SPI::Set_Addr_Window(int16_t x1, int16_t y1, int16_t x2, int16_t y2)
{
		uint8_t x_buf[] = {(x1+xoffset)>>8, (x1+xoffset)&0xFF, (x2+xoffset)>>8, (x2+xoffset)&0xFF};

I tried to typecast it but the warning didn't go away.

		uint8_t x_buf[] = {((uint8_t)(x1+xoffset)>>8), ((uint8_t)(x1+xoffset)&0xFF), ((uint8_t)(x2+xoffset)>>8), ((uint8_t)(x2+xoffset)&0xFF)};

Where xoffset is declared in the header file as:

uint8_t xoffset;

What is the problem now ? why the warning didn't go away ?

==================================================================

also this one:

large integer implicitly truncated to unsigned type [-Woverflow]

in this code:

#define write8(d) Spi_Write(d)

The one above it is commented:

//#define write8(d) {Spi_Write(d);}

What does this warning mean and how to solve it ?

It looks like you are trying to stuff a variable value derived from 16 bit values (x1, x2) into an 8 bit value. Why not make the x_buf[] variable int16_t?

We usually prefer that you post the whole code so that we have context. Then pull snippets to post to illustrate the problem areas.

When you post error messages, please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

1 Like

The result of (x1+offset) and also (x2+offset) are being typecast into a uint8_t (8-bit int) value. The resulting value is then rotated 8 bits to the right. What result would you expect from this? You probably meant to put brackets around the whole expression, i.e. ((uint8_t)((x1+offset)>>8)).

However, as groundFungus pointed out, provided the result of x1+offset or x2+offset will never exceed the maximum value for a 16-bit int (32768) or uint (65535), which is unlikely for Arduino display geometry, it might be easier to just change x_buff into an int16_t or uint16_t.

1 Like

The code from LCDWIKI for ST7796S TFT:

// Sets the LCD address window 
void LCDWIKI_SPI::Set_Addr_Window(int16_t x1, int16_t y1, int16_t x2, int16_t y2)
{
	CS_ACTIVE;
	if((lcd_driver == ID_932X) || (lcd_driver == ID_9225)) 
	{

	    // Values passed are in current (possibly rotated) coordinate
	    // system.  932X requires hardware-native coords regardless of
	    // MADCTL, so rotate inputs as needed.  The address counter is
	    // set to the top-left corner -- although fill operations can be
	    // done in any direction, the current screen rotation is applied
	    // because some users find it disconcerting when a fill does not
	    // occur top-to-bottom.
	    int x, y, t;
	    switch(rotation) 
		{
		     default:
			      x  = x1;
			      y  = y1;
			      break;
		     case 1:
			      t  = y1;
			      y1 = x1;
			      x1 = WIDTH  - 1 - y2;
			      y2 = x2;
			      x2 = WIDTH  - 1 - t;
			      x  = x2;
			      y  = y1;
		      	  break;
		     case 2:
			      t  = x1;
			      x1 = WIDTH  - 1 - x2;
			      x2 = WIDTH  - 1 - t;
			      t  = y1;
			      y1 = HEIGHT - 1 - y2;
			      y2 = HEIGHT - 1 - t;
			      x  = x2;
			      y  = y2;
			      break;
		     case 3:
			      t  = x1;
			      x1 = y1;
			      y1 = HEIGHT - 1 - x2;
			      x2 = y2;
			      y2 = HEIGHT - 1 - t;
			      x  = x1;
			      y  = y2;
			      break;
    	}
		if(lcd_driver == ID_932X)
		{
   			writeCmdData16(ILI932X_HOR_START_AD, x1); // Set address window
    		writeCmdData16(ILI932X_HOR_END_AD, x2);
    		writeCmdData16(ILI932X_VER_START_AD, y1);
    		writeCmdData16(ILI932X_VER_END_AD, y2);
			writeCmdData16(ILI932X_GRAM_HOR_AD, x ); // Set address counter to top left
    		writeCmdData16(ILI932X_GRAM_VER_AD, y );
		}
		else if(lcd_driver == ID_9225)
		{
			writeCmdData16(0x36, x2);
			writeCmdData16(0x37, x1);
			writeCmdData16(0x38, y2);
			writeCmdData16(0x39, y1);
			writeCmdData16(XC, x);
			writeCmdData16(YC, y);
			writeCmd8(CC);

		}
 	} 
	else if(lcd_driver == ID_7575)
	{
		writeCmdData8(HX8347G_COLADDRSTART_HI, x1>>8);
		writeCmdData8(HX8347G_COLADDRSTART_LO, x1);
		writeCmdData8(HX8347G_ROWADDRSTART_HI, y1>>8);
		writeCmdData8(HX8347G_ROWADDRSTART_LO, y1);
		writeCmdData8(HX8347G_COLADDREND_HI, x2>>8);
		writeCmdData8(HX8347G_COLADDREND_LO, x2);
		writeCmdData8(HX8347G_ROWADDREND_HI, y2>>8);
		writeCmdData8(HX8347G_ROWADDREND_LO, y2);
	}
	else if(lcd_driver == ID_1283A)
	{
		int16_t t1, t2;
		switch(rotation)
		{
			case 0:
			case 2:
				t1=x1;
				t2=x2;
				x1=y1+2;
				x2=y2+2;
				y1=t1+2;
				y2=t2+2;
				break;				
			case 1:
			case 3:			
				y1=y1+2;
				y2=y2+2;
				break;
		}
		writeCmd8(XC);
		writeData8(x2);
		writeData8(x1);
		writeCmd8(YC);
		writeData8(y2);
		writeData8(y1);
		writeCmd8(0x21);
		writeData8(x1);
		writeData8(y1);
		writeCmd8(CC);
	}
	else if(lcd_driver == ID_1106)
	{
		return;
	}
	else if(lcd_driver == ID_7735_128)
	{
		uint8_t x_buf[] = {((uint8_t)(x1+xoffset)>>8), ((uint8_t)(x1+xoffset)&0xFF), ((uint8_t)(x2+xoffset)>>8), ((uint8_t)(x2+xoffset)&0xFF)};
		uint8_t y_buf[] = {(y1+yoffset)>>8, (y1+yoffset)&0xFF, (y2+yoffset)>>8, (y2+yoffset)&0xFF};
		Push_Command(XC, x_buf, 4);
		Push_Command(YC, y_buf, 4);
	}
	else
	{
		uint8_t x_buf[] = {x1>>8, x1&0xFF, x2>>8, x2&0xFF};
		uint8_t y_buf[] = {y1>>8, y1&0xFF, y2>>8, y2&0xFF};
	
		Push_Command(XC, x_buf, 4);
		Push_Command(YC, y_buf, 4);
	}
	CS_IDLE;		
}

Warning messages:

D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp: In member function 'virtual void LCDWIKI_SPI::Set_Addr_Window(int16_t, int16_t, int16_t, int16_t)':
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:703:44: warning: narrowing conversion of '(((int)((uint8_t)(x1 + ((int)((LCDWIKI_SPI*)this)->LCDWIKI_SPI::xoffset)))) >> 8)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t x_buf[] = {((uint8_t)(x1+xoffset)>>8), ((uint8_t)(x1+xoffset)&0xFF), ((uint8_t)(x2+xoffset)>>8), ((uint8_t)(x2+xoffset)&0xFF)};
                      ~~~~~~~~~~~~~~~~~~~~~~^~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:703:72: warning: narrowing conversion of '(int)(((unsigned char)((int)((uint8_t)(x1 + ((int)((LCDWIKI_SPI*)this)->LCDWIKI_SPI::xoffset))))) & 255)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t x_buf[] = {((uint8_t)(x1+xoffset)>>8), ((uint8_t)(x1+xoffset)&0xFF), ((uint8_t)(x2+xoffset)>>8), ((uint8_t)(x2+xoffset)&0xFF)};
                                                  ~~~~~~~~~~~~~~~~~~~~~~^~~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:703:102: warning: narrowing conversion of '(((int)((uint8_t)(x2 + ((int)((LCDWIKI_SPI*)this)->LCDWIKI_SPI::xoffset)))) >> 8)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t x_buf[] = {((uint8_t)(x1+xoffset)>>8), ((uint8_t)(x1+xoffset)&0xFF), ((uint8_t)(x2+xoffset)>>8), ((uint8_t)(x2+xoffset)&0xFF)};
                                                                                ~~~~~~~~~~~~~~~~~~~~~~^~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:703:130: warning: narrowing conversion of '(int)(((unsigned char)((int)((uint8_t)(x2 + ((int)((LCDWIKI_SPI*)this)->LCDWIKI_SPI::xoffset))))) & 255)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t x_buf[] = {((uint8_t)(x1+xoffset)>>8), ((uint8_t)(x1+xoffset)&0xFF), ((uint8_t)(x2+xoffset)>>8), ((uint8_t)(x2+xoffset)&0xFF)};
                                                                                                            ~~~~~~~~~~~~~~~~~~~~~~^~~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:704:34: warning: narrowing conversion of '((y1 + ((int)((LCDWIKI_SPI*)this)->LCDWIKI_SPI::yoffset)) >> 8)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t y_buf[] = {(y1+yoffset)>>8, (y1+yoffset)&0xFF, (y2+yoffset)>>8, (y2+yoffset)&0xFF};
                      ~~~~~~~~~~~~^~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:704:51: warning: narrowing conversion of '((y1 + ((int)((LCDWIKI_SPI*)this)->LCDWIKI_SPI::yoffset)) & 255)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t y_buf[] = {(y1+yoffset)>>8, (y1+yoffset)&0xFF, (y2+yoffset)>>8, (y2+yoffset)&0xFF};
                                       ~~~~~~~~~~~~^~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:704:70: warning: narrowing conversion of '((y2 + ((int)((LCDWIKI_SPI*)this)->LCDWIKI_SPI::yoffset)) >> 8)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t y_buf[] = {(y1+yoffset)>>8, (y1+yoffset)&0xFF, (y2+yoffset)>>8, (y2+yoffset)&0xFF};
                                                          ~~~~~~~~~~~~^~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:704:87: warning: narrowing conversion of '((y2 + ((int)((LCDWIKI_SPI*)this)->LCDWIKI_SPI::yoffset)) & 255)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t y_buf[] = {(y1+yoffset)>>8, (y1+yoffset)&0xFF, (y2+yoffset)>>8, (y2+yoffset)&0xFF};
                                                                           ~~~~~~~~~~~~^~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:710:24: warning: narrowing conversion of '(x1 >> 8)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t x_buf[] = {x1>>8, x1&0xFF, x2>>8, x2&0xFF};
                      ~~^~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:710:31: warning: narrowing conversion of '(x1 & 255)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t x_buf[] = {x1>>8, x1&0xFF, x2>>8, x2&0xFF};
                             ~~^~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:710:40: warning: narrowing conversion of '(x2 >> 8)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t x_buf[] = {x1>>8, x1&0xFF, x2>>8, x2&0xFF};
                                      ~~^~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:710:47: warning: narrowing conversion of '(x2 & 255)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t x_buf[] = {x1>>8, x1&0xFF, x2>>8, x2&0xFF};
                                             ~~^~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:711:24: warning: narrowing conversion of '(y1 >> 8)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t y_buf[] = {y1>>8, y1&0xFF, y2>>8, y2&0xFF};
                      ~~^~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:711:31: warning: narrowing conversion of '(y1 & 255)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t y_buf[] = {y1>>8, y1&0xFF, y2>>8, y2&0xFF};
                             ~~^~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:711:40: warning: narrowing conversion of '(y2 >> 8)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t y_buf[] = {y1>>8, y1&0xFF, y2>>8, y2&0xFF};
                                      ~~^~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:711:47: warning: narrowing conversion of '(y2 & 255)' from 'int16_t {aka int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t y_buf[] = {y1>>8, y1&0xFF, y2>>8, y2&0xFF};
                                             ~~^~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp: In member function 'uint16_t LCDWIKI_SPI::Read_ID()':
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:912:31: warning: left shift count >= width of type [-Wshift-count-overflow]
   ret = (Read_Reg(0xD0, 0) << 16) | Read_Reg(0xD0, 1);
                               ^~
In file included from D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:24:0:
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp: In member function 'void LCDWIKI_SPI::Set_Rotation(uint8_t)':
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\mcu_spi_magic.h:5:30: warning: large integer implicitly truncated to unsigned type [-Woverflow]
 #define write8(d) Spi_Write(d)
                              ^
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\mcu_spi_magic.h:63:91: note: in expansion of macro 'write8'
 #define writeCmdData16(a, d)  CD_COMMAND; write8(a>>8); write8(a); CD_DATA; write8(d>>8); write8(d)
                                                                                           ^~~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:1223:5: note: in expansion of macro 'writeCmdData16'
     writeCmdData16(0x01, 0x2183);
     ^~~~~~~~~~~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\mcu_spi_magic.h:5:30: warning: large integer implicitly truncated to unsigned type [-Woverflow]
 #define write8(d) Spi_Write(d)
                              ^
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\mcu_spi_magic.h:63:91: note: in expansion of macro 'write8'
 #define writeCmdData16(a, d)  CD_COMMAND; write8(a>>8); write8(a); CD_DATA; write8(d>>8); write8(d)
                                                                                           ^~~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:1224:5: note: in expansion of macro 'writeCmdData16'
     writeCmdData16(0x03, 0x6830);
     ^~~~~~~~~~~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\mcu_spi_magic.h:5:30: warning: large integer implicitly truncated to unsigned type [-Woverflow]
 #define write8(d) Spi_Write(d)
                              ^
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\mcu_spi_magic.h:63:91: note: in expansion of macro 'write8'
 #define writeCmdData16(a, d)  CD_COMMAND; write8(a>>8); write8(a); CD_DATA; write8(d>>8); write8(d)
                                                                                           ^~~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:1228:5: note: in expansion of macro 'writeCmdData16'
     writeCmdData16(0x01, 0x2283);
     ^~~~~~~~~~~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\mcu_spi_magic.h:5:30: warning: large integer implicitly truncated to unsigned type [-Woverflow]
 #define write8(d) Spi_Write(d)
                              ^
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\mcu_spi_magic.h:63:91: note: in expansion of macro 'write8'
 #define writeCmdData16(a, d)  CD_COMMAND; write8(a>>8); write8(a); CD_DATA; write8(d>>8); write8(d)
                                                                                           ^~~~~~
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:1229:5: note: in expansion of macro 'writeCmdData16'
     writeCmdData16(0x03, 0x6838);
     ^~~~~~~~~~~~~~
Sketch uses 18100 bytes (56%) of program storage space. Maximum is 32256 bytes.
Global variables use 1475 bytes (72%) of dynamic memory, leaving 573 bytes for local variables. Maximum is 2048 bytes.

Yes, the compiler is warning you that the result may not be what you expected. You will see that in the above, the up arrow is pointing at the '>>' indicating the position of the detected problem. This is because if you take the result of adding the two 16-bit variables x1+xoffset and convert that into an 8-bit integer, firstly you loose bits 9-16, so if the result is greater than 256, the upper bits containing that information are lost. The compiler accepts the casting instruction, but it is warning that narrowing from 16-bit to 8-bit will loose precision. Secondly, If you then shift the resulting 8-bit value by 8-bits right, you are, in effect, left with zero, which is almost certainly not what was intended.

You are probably better off doing:

uint16_t x_buf[] = { ((x1+xoffset)>>8), ((x1+xoffset)&0xFF), ((x2+xoffset)>>8), ((x2+xoffset)&0xFF) };

as groundFungus suggested. Everything is then stored as 16-bit integer values. The largest value stored must not be greater than that which is capable of being stored in a 16-bit unsigned int, i.e. 65535.

1 Like

The complier is saying that a fish this big b0 b1 b2 b3 b4 b5 b6 b7 cannot properly eat a fish this big b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15. That some portion of the bigger fish will be chopped off so it can fit into the little fish.

Not sure of cast precedence, but instead of (for axample):

Which I think casts to int8_t then shift left, try

(uint8_t)((x1+xoffset)>>8)
1 Like

I did this and moved to the next type of warnings.

Now I'm working on this:

	uint16_t ret;
	if ((Read_Reg(0x04, 0) == 0x00)&&(Read_Reg(0x04, 1) == 0x8000))
	{
		uint8_t buf[] = {0xFF, 0x83, 0x57};
		Push_Command(HX8357D_SETC, buf, sizeof(buf));
		ret = (Read_Reg(0xD0, 0) << 16) | Read_Reg(0xD0, 1);
		if((ret == 0x990000) || (ret == 0x900000))
		{
			return 0x9090;
		}
	}

I get this warning:

D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp: In member function 'uint16_t LCDWIKI_SPI::Read_ID()':
D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:912:42: warning: left shift count >= width of type [-Wshift-count-overflow]
   ret = ((uint16_t)(Read_Reg(0xD0, 0) << 16) | Read_Reg(0xD0, 1));
                                          ^~

That caused another problem:

D:\Program_Files\Arduino\libraries\LCDWIKI_SPI\LCDWIKI_SPI.cpp:719:28: error: no matching function for call to 'LCDWIKI_SPI::Push_Command(uint16_t&, uint16_t [4], int)'
   Push_Command(YC, y_buf, 4);
                            ^

I think 2nd argument in Push_Command should be 8 bits, so I guess I have to move on with the casting approach.

Ok, so Push_Command wants an array containing 8-bit values. In that case maybe the solution is to bracket the complete calculation before casting it as suggested by willem43, i.e:

uint8_t x_buf[] = { (uint8_t)((x1+xoffset)>>8), (uint8_t)((x1+xoffset)&0xFF), (uint8_t)((x2+xoffset)>>8), (uint8_t)((x2+xoffset)&0xFF) };
uint8_t y_buf[] = { (uint8_t)((y1+yoffset)>>8), (uint8_t)((y1+yoffset)&0xFF), (uint8_t)((y2+yoffset)>>8), (uint8_t)((y2+yoffset)&0xFF) };
1 Like

OK, thank you for the help.

I'm still working on the warning in #8 if you have any idea of how to solve it.

My question is this:

ret = (Read_Reg(0xD0, 0) << 16) | Read_Reg(0xD0, 1);

Caused a warning:

warning: left shift count >= width of type

Now why the author shift a 16-bit variable 16 times ?

OK, here's my guess:

	uint16_t ret;
	if ((Read_Reg(0x04, 0) == 0x00)&&(Read_Reg(0x04, 1) == 0x8000))
	{
		uint8_t buf[] = {0xFF, 0x83, 0x57};
		Push_Command(HX8357D_SETC, buf, sizeof(buf));
		ret = (Read_Reg(0xD0, 0) << 16) | Read_Reg(0xD0, 1);
		if((ret == 0x990000) || (ret == 0x900000))
		{
			return 0x9090;
		}
	}

I think because it will be used in the if statement as 24-bit values:
if((ret == 0x990000) || (ret == 0x900000))

So I think I should declare ret as 32-bit variable. Is my conclusion correct ?


Update:

I actually declared ret as 32-bit variable and all the warnings got cleared.

Yes, similar type of problem. The statement was an instruction to shift a register value 16 bits to the left, but the receiving variable type of 'ret' was only 16 bits wide and not big enough to store the result. Changing 'ret' to a 32-bit type provided the space needed. Glad you was able to work out the solution to clear the warnings. Well done.

1 Like

Yep, but anyway the function doesn't work, which its work is to return the ID model of the TFT driver.

The LCDWIKI is a big library supporting multiple TFTs, I removed many code for the other models and kept the stuff for the TFTs I have which are ILI9488 and ST7796S, I lowered the compiled code from %56 to %42, still a heavy code.

I can split the code into two libraries and lower the code even more.

I'm now moving to get the touch panel to work.

The library likely compiles well, or at least "better", on a processor with native 32-bit integers, no? Did you perchance miss a notation to that effect somewhere?

Yep, it should work with 32 microcontrollers. But I think after post #11, I managed to solve the problem.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.