Adafruit display + code structure = not working :(

I have an Adafruit TFT display which I have working successfully via Platform IO using separate .ccp and header files as a basic proof of concept.

When I have ported this exact config into my real project it simply displays a white screen as opposed to the black with my yellow test text.

Can't think for the life of me why this would break :frowning: This is a stand alone file which can be uploaded via Arduino IDE and provide basic functionality also:

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <SPI.h>

#define TFT_CS        10
#define TFT_RST        9 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC         8

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void) {
  tft.initR(INITR_BLACKTAB);
  tft.setRotation(3);
  tft.setTextWrap(false);
  tft.fillScreen(ST77XX_BLACK);
  tft.setCursor(0, 0);
  tft.setTextColor(ST77XX_YELLOW);
  tft.setTextSize(2);
      
  tftPrintTest();
}

void loop() {
}

void tftPrintTest() {
  tft.println("TEST");
}

A link to my commit of these test files is as per the below in my real project, I don't have the files for the test with broken out header and .cpp file for display content but it worked just fine.

So the summary at this stage is:

  • WORKED: Taking the above very basic code to drive the display and splitting it out into the same structure as my main code worked just fine as a stand alonetest.
  • NOT WORK: Once simply lifting and shifting the working stand alone code into my main project / code it no longer works.

The below commit shows the code split out into the main code base which then does NOT work.

you'll get more responses if you post you code (using the </> icons) instead of making people have to download you git repository

Thankyou, have made the first part inline and added some more clear context. The second part is more useful linking through to Github still otherwise its too hard to explain etc.

I've recreated the stand alone code which drives the screen no problem ... this is what I have simply copy / pasted into my main code where it does NOT function. Its just the other code which I put inline, but split into multiple files.

Adafruit_Display_Test/src at master · david-morton/Adafruit_Display_Test · GitHub

Turns out to be very simple, conflicting pins used for the comms to the display and my CAN shields !! Hence it only did not work when in my main code.

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