Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 31 of 31

Thread: New adafruit GFX 1.4.x libs doesn't work for me

  1. #26
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    4,546
    Quote Originally Posted by PaulStoffregen View Post
    Ughhh - retesting here and I also get the black screen issue.

    Earlier I tested with version 1.2.4. Looks like something broke starting with version 1.2.6. I'm putting this library back on my list of issues to investigate.

    Just to be realistic, I probably won't be able to dig into what went wrong for at least a couple weeks. In the meantime, I recommend using the library manager to uninstall 1.2.8 and install version 1.2.5. I tested just now and 1.2.5 seems to be working fine.

    Here's how the buttons render at the end of "graphictest" with 1.2.5.

    Attachment 16360
    For the heck of it, I picked up an ST7789 from Amazon (https://smile.amazon.com/MakerFocus-.../dp/B07P9X3L7M)
    But not sure if it will actually work?
    That is the pins are marked(GND, VCC, SCL, SDA, RES, DC, BLK)
    i.e. no CS pin?

  2. #27
    Member tcottle's Avatar
    Join Date
    Dec 2014
    Location
    Longmont, CO
    Posts
    39
    Well I have made some more progress. I don't think that it is a problem in the Teensy though. I suspect that the library is broken from 1.26 to 1.29 but I do not have a real Arduino board to verify on (everything that I have on hand is a Teensy 3.X )

    The problem is in the ST77XX displayInit method in Adafruit_ST77xx.cpp. The routine spits out a standard display initialization sequence.

    Here is 1.25
    Code:
    void Adafruit_ST77xx::displayInit(const uint8_t *addr) {
    
      uint8_t  numCommands, numArgs;
      uint16_t ms;
    
      numCommands = pgm_read_byte(addr++);   // Number of commands to follow
      while(numCommands--) {                 // For each command...
        startWrite();
    
        writeCommand(pgm_read_byte(addr++)); //   Read, issue command
        numArgs  = pgm_read_byte(addr++);    //   Number of args to follow
        ms       = numArgs & ST_CMD_DELAY;   //   If hibit set, delay follows args
        numArgs &= ~ST_CMD_DELAY;            //   Mask out delay bit
        while(numArgs--) {                   //   For each argument...
          spiWrite(pgm_read_byte(addr++));  //     Read, issue argument
        }
        endWrite();
    
        if(ms) {
          ms = pgm_read_byte(addr++); // Read post-command delay time (ms)
          if(ms == 255) ms = 500;     // If 255, delay for 500 ms
          delay(ms);
        }
      }
    }
    and 1.26.

    Code:
    void Adafruit_ST77xx::displayInit(const uint8_t *addr) {
    
      uint8_t  numCommands, numArgs;
      uint16_t ms;
    
      startWrite();
      numCommands = pgm_read_byte(addr++);   // Number of commands to follow
      while(numCommands--) {                 // For each command...
    
        writeCommand(pgm_read_byte(addr++)); // Read, issue command
        numArgs  = pgm_read_byte(addr++);    // Number of args to follow
        ms       = numArgs & ST_CMD_DELAY;   // If hibit set, delay follows args
        numArgs &= ~ST_CMD_DELAY;            // Mask out delay bit
        while(numArgs--) {                   // For each argument...
          spiWrite(pgm_read_byte(addr++));   // Read, issue argument
        }
    
        if(ms) {
          ms = pgm_read_byte(addr++); // Read post-command delay time (ms)
          if(ms == 255) ms = 500;     // If 255, delay for 500 ms
          delay(ms);
        }
      }
      endWrite();
    }
    The startWrite() and endWrite() routines were moved outside of the while loop (for unknown reasons) and this is what breaks on the ST7789 display

    They seem to have noticed this and and tried to toggle the CS line inside the while loop as a patch for the ST7789. It didn't work

    1.29
    Code:
    void Adafruit_ST77xx::displayInit(const uint8_t *addr) {
    
      uint8_t  numCommands, numArgs;
      uint16_t ms;
    
      startWrite();
      numCommands = pgm_read_byte(addr++);   // Number of commands to follow
      while(numCommands--) {                 // For each command...
    
        writeCommand(pgm_read_byte(addr++)); // Read, issue command
        numArgs  = pgm_read_byte(addr++);    // Number of args to follow
        ms       = numArgs & ST_CMD_DELAY;   // If hibit set, delay follows args
        numArgs &= ~ST_CMD_DELAY;            // Mask out delay bit
        while(numArgs--) {                   // For each argument...
          spiWrite(pgm_read_byte(addr++));   // Read, issue argument
        }
        SPI_CS_HIGH(); SPI_CS_LOW();  // ST7789 needs chip deselect after each
    
        if(ms) {
          ms = pgm_read_byte(addr++); // Read post-command delay time (ms)
          if(ms == 255) ms = 500;     // If 255, delay for 500 ms
          delay(ms);
        }
      }
      endWrite();
    }
    so here is a patched 1.29 routine that works for me

    Code:
    void Adafruit_ST77xx::displayInit(const uint8_t *addr) {
    
      uint8_t  numCommands, numArgs;
      uint16_t ms;
    
    
      numCommands = pgm_read_byte(addr++);   // Number of commands to follow
      while(numCommands--) {                 // For each command...
    	startWrite();
    
        writeCommand(pgm_read_byte(addr++)); // Read, issue command
        numArgs  = pgm_read_byte(addr++);    // Number of args to follow
        ms       = numArgs & ST_CMD_DELAY;   // If hibit set, delay follows args
        numArgs &= ~ST_CMD_DELAY;            // Mask out delay bit
        while(numArgs--) {                   // For each argument...
          spiWrite(pgm_read_byte(addr++));   // Read, issue argument
        }
    //    SPI_CS_HIGH(); SPI_CS_LOW();  // ST7789 needs chip deselect after each
    	endWrite();
    
        if(ms) {
          ms = pgm_read_byte(addr++); // Read post-command delay time (ms)
          if(ms == 255) ms = 500;     // If 255, delay for 500 ms
          delay(ms);
        }
      }
    }
    Click image for larger version. 

Name:	IMG_4870.jpg 
Views:	5 
Size:	196.1 KB 
ID:	16411

  3. #28
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,922
    Quote Originally Posted by tcottle View Post
    They seem to have noticed this and and tried to toggle the CS line inside the while loop as a patch for the ST7789. It didn't work
    Oh, that's probably not going to work on Teensy 3.6 if they're using direct register I/O. The pins default to slew rate limiting, which is a feature you definitely do want if running the signals over those inches-long wires. With slew rate limiting, back-to-back writes directly to the register on Teensy 3.6 runs so fast (only 5 or 10 ns) that the pin's voltage can't fully change!

  4. #29
    Member tcottle's Avatar
    Join Date
    Dec 2014
    Location
    Longmont, CO
    Posts
    39
    Hmmm can't edit my old post - anyway please change the references to 1.29 to 1.28 (the latest issue)

    Based on Paul's insight I grabbed a fresh copy of 1.28 and added a 10uS delay between CS_HIGH and CS_LOW. Pleased to report that it now works with this change only. Tried smaller delays and for my breadboard setup with long leads 3uS was the shortest delay that would still work

  5. #30
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,922
    Would you consider opening an issue on Adafruit's github repository for this library?

  6. #31
    Member tcottle's Avatar
    Join Date
    Dec 2014
    Location
    Longmont, CO
    Posts
    39
    Sure (once I figure out how to :-D)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •