Bodmer / TFT_HX8357

Arduino library for HX8357 TFT display
118 stars 52 forks source link

Thanks - But can you help. #43

Closed 1martinlipka closed 3 years ago

1martinlipka commented 3 years ago

Hi,

I bought a TFT display from ebay. It said it was ILI9486. It has a 16bit parallel interface. I tried a few libraries, and this was the one that could produce any output.

I had to fix a lot of things - and the white screen was first - after picking apart the datasheet and the initialisation code - I found that setting the power option P3 (Command 0xC2) - just produced a white screen - commenting that out gave me screen output.

However - the data was not right. I've basically doubled every write strobe where data is involved - and now I almost get what I am expecting; lines, circles, interlaced text, etc. The interlaced text I have fixed previously, but I am going after an elegant solution, so 2 steps forward one step backwards.

Any thoughts as to what I might be looking at? Why two write strobes might be necessary? I tried removing compiler optimisations, adding NOPs into the strobes, to verify I wasn't looking at a race condition, but this had no effect. Is there some panel diagnostics that you know of so I can figure out if I am actually looking at a ILI9486?

Thanks

Martin

1martinlipka commented 3 years ago

Okay - I kept poking, yet I haven't figured out how to read from this device; can anyone shed some light on this?

so far ;

TFT_HX8357.h // now define the reads.

define READ_PIN 6 // LCD_RD is PL6 pin 43

define READ_PORT PORTL

#define RD_L READ_PORT&=~_BV(READ_PIN);
#define RD_H READ_PORT|=_BV(READ_PIN);
#define RD_STB READ_PORT&=~_BV(READ_PIN); READ_PORT|=_BV(READ_PIN);

TFT_HX8357.cpp //in constructor _rd = 43; // PORT L bit _BV(6) pinMode(_rd, OUTPUT);

//new functions; / Function name: readdata Description: Get a 16bit byte back from the display / uint16_t TFT_HX8357::readdata() { SETUP_CS_L; uint16_t Data = 0 ; RD_L ; NOP ; RD_H ; Data = PINC & 0x00FF; Data |= PINA << 8 ; SETUP_CS_H; return Data ; }

// write a command and then read the result. // Data must hold at least DataSize uint16_t structures to prevent buffer overruns. // void TFT_HX8357::readCommand(uint8_t Command, uint16_t DataSize, uint16_t * Data) { // SETUP_CS_L; // this should be pushed low for the duration of the read.

writecommand(Command) ;
// force ports A and C to input.
DDRA = 0x00 ;
DDRC = 0x00 ;
// force pull up - off.
PORTA = 0x00 ;
PORTC = 0x00 ;

// read the bytes - note Data[0] is unually invalid.
for (int i = 0 ; i < DataSize ; i++)
{
    Data[i] = readdata() ;
}

// restore port direction state.
DDRA = 0xFF ;
DDRC = 0xFF ;

// SETUP_CS_H; }

and in the setup code; (sketch) void TestReadData() { // now read the bytes back uint16_t Data[4] ; tft.readCommand(HX8357_RDDID,4,Data) ; // spit out the results. Serial.print("Returned Bytes: 0x") ; Serial.print(Data[0],HEX) ; Serial.print(" : 0x") ; Serial.print(Data[1],HEX) ; Serial.print(" : 0x") ; Serial.print(Data[2],HEX) ; Serial.print(" : 0x") ; Serial.println(Data[3],HEX) ;

}

1martinlipka commented 3 years ago

Okay - I got it. The board has an 8 bit interface - therefore it needs double the writing of a 16 bit interface. Also - the board is broken when it comes to reading - it does not allow reading. My code above (with a bit of massaging) should be suitable to add reading functionality to this library