Adafruit_ST7789 setting SPI_MODE

I had to hard code SPI_MODE3 into Adafruit_ST7789.cpp. I couldn't find a way to set it. After I hardcoded, the example program runs fine.

Is there a way to set it?

mega 2560. hardware spi.

// Here's the code I set in Adafruit_ST7789.cpp

void Adafruit_ST7789::init(uint16_t width, uint16_t height, uint8_t mode) {
  // Save SPI data mode. commonInit() calls begin() (in Adafruit_ST77xx.cpp),
  // which in turn calls initSPI() (in Adafruit_SPITFT.cpp), passing it the
  // value of spiMode. It's done this way because begin() really should not
  // be modified at this point to accept an SPI mode -- it's a virtual
  // function required in every Adafruit_SPITFT subclass and would require
  // updating EVERY such library...whereas, at the moment, we know that
  // certain ST7789 displays are the only thing that may need a non-default
  // SPI mode, hence this roundabout approach...
    //spiMode = mode;
    spiMode = SPI_MODE3; // <--- Hard coded
  // case-by-case basis.)

I found the answer in another question. The init() accepts a mode. I was trying to init() outside the setup( void ){} section. That didn't work. I don't know why. When I moved it inside, everything was fine.

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