MadeByJK / Adafruit_SPFD5408_8bit_STM32

Adafruit TFT library for 8 bit displays with SPFD5408 controller working on STM32 boards
3 stars 1 forks source link

Colours inverse and strange rotation issue #1

Open NonDualChris opened 3 years ago

NonDualChris commented 3 years ago

Hi Many thanks for creating this library. I purchased this TFT display - https://www.ebay.co.uk/itm/313148042885. The item states that it has 'SPFD5408 controller with built in video RAM buffer'.

I am getting two issues using this library with this particular device (although I am happy to report that I am getting something on the screen, where I was not doing with the ILI9341 libraries).

First of all, the colours are inverse, so 0x0000 gives white and 0xFFFF gives black. The other colours are wrong in corresponding fashion.

The second issue I have is that my simple rotation sketch here results in only a square proportion of the screen being used.


include // Core graphics library

include // Hardware-specific library

define BLACK 0x0000

define BLUE 0x001F

define RED 0xF800

define GREEN 0x07E0

define CYAN 0x07FF

define MAGENTA 0xF81F

define YELLOW 0xFFE0

define WHITE 0xFFFF

Adafruit_SPFD5408_8bit_STM32 tft;

void setup() { tft.reset(); tft.begin(); tft.setRotation(3);
delay(100); }

void loop() { tft.fillScreen(BLACK); tft.setCursor(10, 100); tft.setTextColor(BLUE); tft.setTextSize(3); tft.println("This is a test of the TFT Display"); delay(3000); }

I appreciate any help. Thank you

P.S. This is not a faulty hardware issue - I am confused why my small example sketch shown here gives a bad image.

badimage

NonDualChris commented 3 years ago

Further . . . the command 'tft.invertDisplay(1);' seems to have no effect whatsoever when called at any point within the sketch.

NonDualChris commented 3 years ago

PARTIAL SOLUTION: I altered the following lines in the Adafruit_SPFD5408_8bit_STM32.h file.

From:

define TFTWIDTH 240

define TFTHEIGHT 320

To:

define TFTWIDTH 320

define TFTHEIGHT 240

The screen rotation is now fixed for the graphical utilities in the library! I've altered the colours to inverted versions using the following defines in the main sketch . . . botchy but it works:

define BLACK 0xFFFF

define BLUE 0xFFE0

define RED 0x07FF

define GREEN 0xF81F

define CYAN 0xF800

define MAGENTA 0x07E0

define YELLOW 0x001F

define WHITE 0x0000

However, there still appears to be an issue when PRINTing to the TFT. The text is still cut-off . . . due to the parameters of width and height being reversed somewhere. The graphical functions work as normal but printing is still a problem area.

All the best Chris

NonDualChris commented 3 years ago

I fixed the text issue. I altered the ADAFRUIT_GFX.cpp file. I switched around the two widths and heights so they were swapped in reverse. This code is the fix.

void Adafruit_GFX::setRotation(uint8_t x) { rotation = (x & 3); switch(rotation) { case 0: case 2: _width = HEIGHT; _height = WIDTH; break; case 1: case 3: _width = WIDTH; _height = HEIGHT; break; } }

Chris