adafruit / Adafruit-GFX-Library

Adafruit GFX graphics core Arduino library, this is the 'core' class that all our other graphics libraries derive from
https://learn.adafruit.com/adafruit-gfx-graphics-library
Other
2.32k stars 1.52k forks source link

fillScreen not working (issue with setAddrWindow?) #440

Open kittenarmy opened 7 months ago

kittenarmy commented 7 months ago

I know it isn't official supported hardware, but I really was hoping someone familiar with the codebase would be able to help as I am trying to get this screen to work and it feels so close to being solved. Seems like the other functions in GFX library are working in the project, just this snag about painting the whole screen with fillScreen (see pics it doesn't appear to paint at all, so things are drawn over each other).

I can't seem to call setAddrWindow from my code separately as it won't execute/crashes.

Hardware is (possibly) ILI9325 display, STM32F103C8, Arduino 1.8.19.

I am using an older version Adafruit GFX 1.2.7 as it seems to work with most of the (old/abandoned) project code without throwing lots of compile errors.

Here is a test sketch:

#include <Adafruit_GFX.h>
//using 1.2.7 most compatible
//1.5.5 white screen, many compile errors, no LED
//1.1.4 white screen, multiple errors. many things don't draw.

#include "src/TFTLib/Adafruit_TFTLCD_8bit_STM32.h"

#define ledPin PA15

// TFT display constants
#define PORTRAIT     0
#define LANDSCAPE     3
#define TFT_WIDTH    320
#define TFT_HEIGHT    240

//in portrait 0 I get strange flickering, text begins at piscing
// need for steve strong
//#define ILI9341_BLACK 0x0000
//#define ILI9341_WHITE 0xFFFF

#define ipsum "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

//--------------------led stuff
// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

#define yalign 0
// doesn't matter if unsigned int or define
// xalign still appears ever so slightly lower
// yalign 400 you cant see the text at all, black region top

// constants won't change:
const long interval = 1000;           // interval at which to blink (milliseconds)

Adafruit_TFTLCD_8bit_STM32 tft;

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);

  // try this with serial only
  afio_cfg_debug_ports(AFIO_DEBUG_NONE);
  // led only works with this AFIO_DEBUG_NONE
  // AFIO_DEBUG_SW_ONLY - I only get the first test on serial. no led flashing, white screen

  /*
  Serial.begin(9600);
  // it just hangs if I use serial with debug none
  while (!Serial) {
  ; // wait for serial port
  }
  Serial.println("test");
  */

  // init display
  tft.reset();
  // tft.begin(0x9341);
  // we have ILI9325
  tft.begin(0x9325);
  // 0x9325
  // 0x8357
  // 0x8347
  tft.setRotation(LANDSCAPE);

  // ok how to call setAddrWindow()
  // tft.setAddrWindow(1,1,320,240);
  //this gives me a white screen

  tft.fillScreen(ILI9341_BLACK); // fillScreen has uint32 as len
}

void loop() {
  tft.setCursor(0, yalign);
  tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
  tft.print(ipsum);

  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }
    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }