Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 3 1 2 3 LastLast
Results 1 to 25 of 51

Thread: Teensy 3.2 / Adafruit ST7735 / spitftbitmap Example - Image is off the screen?

  1. #1
    Junior Member
    Join Date
    May 2018
    Posts
    6

    Teensy 3.2 / Adafruit ST7735 / spitftbitmap Example - Image is off the screen?

    I just wired up a 0.96" 160x80 color TFT from Adafruit (https://www.adafruit.com/product/3533) to a Teensy 3.2 with Teensyduino v1.41. I noticed that the parrot.bmp file that ships with the example is 160x128 px. If I leave it at that resolution and put it on the SD card, things work as expected (it looks fine); though obviously since my LCD is smaller than the image, I only see part of the image. However, if I crop that image to the size that the LCD expects - 160x80, then I get a bunch of "snow" on one side of the screen. See attached images.

    I'm using the unmodified example code (other than pinouts) which ships with v1.41. Here's the pins I'm using:

    14 - sclk
    12 - miso
    11 - mosi
    10 - cs
    9 - dc
    8 - rst
    4 - sdcs

    Basically, they are all stock except that I moved sclk from pin 13 to pin 14.

    Here's the trimmed bitmap, in 24-bit color:
    parrot.bmp

    Here's what it looks like on the screen:
    Click image for larger version. 

Name:	parrot-displayed.jpg 
Views:	188 
Size:	43.2 KB 
ID:	13858

    Any ideas? Thanks!
    Last edited by randomfish; 05-20-2018 at 01:07 AM. Reason: corrected image dimensions

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,396
    shouldnt it be 80x160? im just guessing since the original was 128x160...

  3. #3
    Junior Member
    Join Date
    May 2018
    Posts
    6
    I fixed a typo in the image dimensions in the post above (I had the dimensions of the original image flipped). That should be clearer now.

    I've been looking at this some more, and it looks like teensyduino ships an old version of the adafruit library that doesn't support the 160x80 screen. The version on github actually supports a number of different screens (https://github.com/adafruit/Adafruit-ST7735-Library); specifically this file: https://github.com/adafruit/Adafruit...fruit_ST77xx.h

    If I download that library to my local arduino library, it seems to be ignored by the compiler - the one that ships with teensyduino is preferred over it. I tried moving those out of the way and using the new ST77 library, the new adafruit GFX library, and a new SD card library, but it doesnt work. I'm guessing there's some teensy-specific modifications in the version that ships with teensyduino.

  4. #4
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,559
    Teensyduino comes with ST7735_t3.h
    try the examples from that library
    arduino-1.8.5/hardware/teensy/avr/libraries/ST7735_t3/examples/spitftbitmap/

    works for me on 128x160
    Last edited by manitou; 05-20-2018 at 04:42 PM.

  5. #5
    Junior Member
    Join Date
    May 2018
    Posts
    6
    Hmm. I tried that library, but I'm getting the same issue when using the trimmed bitmap. Those header files dont say anything about supporting the 0.96" LCD.

  6. #6
    Senior Member
    Join Date
    May 2017
    Posts
    208
    It looks like your pixel at 0,0 is not in the correct place, off the screen or shifted in about 20 pixels. There are some comments in the example that hint that there may be issues with the placement of the 0,0 coordinate. I would try the suggested options or look at the initR function and make changes to move the image to the right.

    Code:
      // Our supplier changed the 1.8" display slightly after Jan 10, 2012
      // so that the alignment of the TFT had to be shifted by a few pixels
      // this just means the init code is slightly different. Check the
      // color of the tab to see which init code to try. If the display is
      // cut off or has extra 'random' pixels on the top & left, try the
      // other option!
      // If you are seeing red and green color inversion, use Black Tab
    
      // If your TFT's plastic wrap has a Black Tab, use the following:
      tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab
      // If your TFT's plastic wrap has a Red Tab, use the following:
      //tft.initR(INITR_REDTAB);   // initialize a ST7735R chip, red tab
      // If your TFT's plastic wrap has a Green Tab, use the following:
      //tft.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab
    OR

    another potential place in the example is where the image is clipped. Serial print out the results of these calculations to see if your new image is being clipped for some reason.

    Code:
            // Crop area to be loaded
            w = bmpWidth;
            h = bmpHeight;
            if((x+w-1) >= tft.width())  w = tft.width()  - x;
            if((y+h-1) >= tft.height()) h = tft.height() - y;
    
            // Set TFT address window to clipped image bounds
            tft.setAddrWindow(x, y, x+w-1, y+h-1);

  7. #7
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,122
    Again it always helps to see the actual code you are trying... Example did you update the init function as shown in: https://learn.adafruit.com/adafruit-...ut/wiring-test

    If you install the one from Adafruit, I believe the Arduino IDE will default to use that one over the one in the boards directory... When you build the compiler will typically tell you which one it used, with messages like:
    I used This library and did not use that one...

  8. #8
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,559
    Quote Originally Posted by randomfish View Post
    Hmm. I tried that library, but I'm getting the same issue when using the trimmed bitmap. Those header files dont say anything about supporting the 0.96" LCD.

    Ooops, i was testing on 128x160 https://www.adafruit.com/product/358

    the parrot.bmp in the ST7735_t3 lib is 128x160

  9. #9
    Junior Member
    Join Date
    May 2018
    Posts
    6
    A couple updates:

    * I've been using the INITR_REDTAB settings, as those seem to work the best for this LCD.

    * I noticed that if I change:

    Code:
    bmpDraw("parrot.bmp", 0, 0);
    to this:

    Code:
    bmpDraw("parrot.bmp", 24, 0);
    Then it looks correct. I verified that by making a test image that has 1px borders in different colors, and it works as expected then. I guess 24 makes sense: (128 - 80)/2 = 24

    * I havent yet gotten to printing out via serial, but that's next on the list.

    * This is with the Adafruit library located at /opt/arduino-1.8.5/hardware/teensy/avr/libraries/Adafruit_ST7735/examples/spitftbitmap/

    * As mentioned above, I did try the one located at: /opt/arduino-1.8.5/hardware/teensy/avr/libraries/ST7735_t3/examples/spitftbitmap/ but didnt see any difference in the result

    * As also mentioned above, I tried downloading the new version from github to my local libraries folder. I'll elaborate a bit more on that comment though. Teensyduino seems to always prefer the one in /opt (as noted in the compiler output). The only way I got it to recognize my local copy was to move the ones in /opt to a location it couldnt find. When I did that, the version from github doesn't compile unless I also provide a newer SD library and Adafruit_GFX library. Doing that make it compile, but all I get is either an all-white or all-black screen - I'm not sure why it wasn't loading the image. I double-checked the pinouts (which are slightly different for the github version), but didnt find any issue with how I wired it up. So I didn't look into it much farther than poking a few configuration settings in the top of the source files. So I just reverted to a stock teensyduino install, since I seemed to get somewhat farther with the provided code.

    I didn't think it'd be worth posting the code since it's literally the stock example, but here it is anyways:

    Code:
    /***************************************************
      This is an example sketch for the Adafruit 1.8" SPI display.
      This library works with the Adafruit 1.8" TFT Breakout w/SD card
      ----> http://www.adafruit.com/products/358
      as well as Adafruit raw 1.8" TFT display
      ----> http://www.adafruit.com/products/618
    
      Check out the links above for our tutorials and wiring diagrams
      These displays use SPI to communicate, 4 or 5 pins are required to
      interface (RST is optional)
      Adafruit invests time and resources providing this open source code,
      please support Adafruit and open-source hardware by purchasing
      products from Adafruit!
    
      Written by Limor Fried/Ladyada for Adafruit Industries.
      MIT license, all text above must be included in any redistribution
     ****************************************************/
    
    #include <Adafruit_GFX.h>    // Core graphics library
    #include <Adafruit_ST7735.h> // Hardware-specific library
    #include <SPI.h>
    #include <SD.h>
    
    #if defined(__SAM3X8E__)
        #undef __FlashStringHelper::F(string_literal)
        #define F(string_literal) string_literal
    #endif
    
    // This Teensy3 native optimized version requires specific pins
    //
    #define sclk 14  // SCLK can also use pin 14
    #define mosi 11  // MOSI can also use pin 7
    #define cs   10  // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
    #define dc   9   //  but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
    #define rst  8   // RST can use any pin
    #define sdcs 4   // CS for SD card, can use any pin
    
    Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);
    
    void setup(void) {
      Serial.begin(9600);
    
      // Our supplier changed the 1.8" display slightly after Jan 10, 2012
      // so that the alignment of the TFT had to be shifted by a few pixels
      // this just means the init code is slightly different. Check the
      // color of the tab to see which init code to try. If the display is
      // cut off or has extra 'random' pixels on the top & left, try the
      // other option!
      // If you are seeing red and green color inversion, use Black Tab
    
      // If your TFT's plastic wrap has a Black Tab, use the following:
      //tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab
      // If your TFT's plastic wrap has a Red Tab, use the following:
      tft.initR(INITR_REDTAB);   // initialize a ST7735R chip, red tab
      // If your TFT's plastic wrap has a Green Tab, use the following:
      //tft.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab
    
      Serial.print("Initializing SD card...");
      if (!SD.begin(sdcs)) {
        Serial.println("failed!");
        return;
      }
      Serial.println("OK!");
    
      bmpDraw("parrot.bmp", 24, 0);
    }
    
    void loop() {
    }
    
    // This function opens a Windows Bitmap (BMP) file and
    // displays it at the given coordinates.  It's sped up
    // by reading many pixels worth of data at a time
    // (rather than pixel by pixel).  Increasing the buffer
    // size takes more of the Arduino's precious RAM but
    // makes loading a little faster.  20 pixels seems a
    // good balance.
    
    #define BUFFPIXEL 20
    
    void bmpDraw(const char *filename, uint8_t x, uint8_t y) {
    
      File     bmpFile;
      int      bmpWidth, bmpHeight;   // W+H in pixels
      uint8_t  bmpDepth;              // Bit depth (currently must be 24)
      uint32_t bmpImageoffset;        // Start of image data in file
      uint32_t rowSize;               // Not always = bmpWidth; may have padding
      uint8_t  sdbuffer[3*BUFFPIXEL]; // pixel buffer (R+G+B per pixel)
      uint8_t  buffidx = sizeof(sdbuffer); // Current position in sdbuffer
      boolean  goodBmp = false;       // Set to true on valid header parse
      boolean  flip    = true;        // BMP is stored bottom-to-top
      int      w, h, row, col;
      uint8_t  r, g, b;
      uint32_t pos = 0, startTime = millis();
    
      if((x >= tft.width()) || (y >= tft.height())) return;
    
      Serial.println();
      Serial.print("Loading image '");
      Serial.print(filename);
      Serial.println('\'');
    
      // Open requested file on SD card
      if ((bmpFile = SD.open(filename)) == false) {
        Serial.print("File not found");
        return;
      }
    
      // Parse BMP header
      if(read16(bmpFile) == 0x4D42) { // BMP signature
        Serial.print("File size: "); Serial.println(read32(bmpFile));
        (void)read32(bmpFile); // Read & ignore creator bytes
        bmpImageoffset = read32(bmpFile); // Start of image data
        Serial.print("Image Offset: "); Serial.println(bmpImageoffset, DEC);
        // Read DIB header
        Serial.print("Header size: "); Serial.println(read32(bmpFile));
        bmpWidth  = read32(bmpFile);
        bmpHeight = read32(bmpFile);
        if(read16(bmpFile) == 1) { // # planes -- must be '1'
          bmpDepth = read16(bmpFile); // bits per pixel
          Serial.print("Bit Depth: "); Serial.println(bmpDepth);
          if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed
    
            goodBmp = true; // Supported BMP format -- proceed!
            Serial.print("Image size: ");
            Serial.print(bmpWidth);
            Serial.print('x');
            Serial.println(bmpHeight);
    
            // BMP rows are padded (if needed) to 4-byte boundary
            rowSize = (bmpWidth * 3 + 3) & ~3;
    
            // If bmpHeight is negative, image is in top-down order.
            // This is not canon but has been observed in the wild.
            if(bmpHeight < 0) {
              bmpHeight = -bmpHeight;
              flip      = false;
            }
    
            // Crop area to be loaded
            w = bmpWidth;
            h = bmpHeight;
            if((x+w-1) >= tft.width())  w = tft.width()  - x;
            if((y+h-1) >= tft.height()) h = tft.height() - y;
    
            // Set TFT address window to clipped image bounds
            tft.setAddrWindow(x, y, x+w-1, y+h-1);
    
            for (row=0; row<h; row++) { // For each scanline...
    
              // Seek to start of scan line.  It might seem labor-
              // intensive to be doing this on every line, but this
              // method covers a lot of gritty details like cropping
              // and scanline padding.  Also, the seek only takes
              // place if the file position actually needs to change
              // (avoids a lot of cluster math in SD library).
              if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
                pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
              else     // Bitmap is stored top-to-bottom
                pos = bmpImageoffset + row * rowSize;
              if(bmpFile.position() != pos) { // Need seek?
                bmpFile.seek(pos);
                buffidx = sizeof(sdbuffer); // Force buffer reload
              }
    
              for (col=0; col<w; col++) { // For each pixel...
                // Time to read more pixel data?
                if (buffidx >= sizeof(sdbuffer)) { // Indeed
                  bmpFile.read(sdbuffer, sizeof(sdbuffer));
                  buffidx = 0; // Set index to beginning
                }
    
                // Convert pixel from BMP to TFT format, push to display
                b = sdbuffer[buffidx++];
                g = sdbuffer[buffidx++];
                r = sdbuffer[buffidx++];
                tft.pushColor(tft.Color565(r,g,b));
              } // end pixel
            } // end scanline
            Serial.print("Loaded in ");
            Serial.print(millis() - startTime);
            Serial.println(" ms");
          } // end goodBmp
        }
      }
    
      bmpFile.close();
      if(!goodBmp) Serial.println("BMP format not recognized.");
    }
    
    // These read 16- and 32-bit types from the SD card file.
    // BMP data is stored little-endian, Arduino is little-endian too.
    // May need to reverse subscript order if porting elsewhere.
    
    uint16_t read16(File f) {
      uint16_t result;
      ((uint8_t *)&result)[0] = f.read(); // LSB
      ((uint8_t *)&result)[1] = f.read(); // MSB
      return result;
    }
    
    uint32_t read32(File f) {
      uint32_t result;
      ((uint8_t *)&result)[0] = f.read(); // LSB
      ((uint8_t *)&result)[1] = f.read();
      ((uint8_t *)&result)[2] = f.read();
      ((uint8_t *)&result)[3] = f.read(); // MSB
      return result;
    }

  10. #10
    Junior Member
    Join Date
    May 2018
    Posts
    6
    Results of serial debug below. Looks like the most likely candidate is that the library doesnt really support 80px width (it's written for 128px), so the TFT dimensions are wrong in the calculations.

    Code:
    Initializing SD card...OK!
    
    Loading image 'test.bmp'
    tft.width(): 128
    tft.height(): 160
    File size: 38522
    Image Offset: 122
    Header size: 108
    Bit Depth: 24
    Image size: 80x160
    x: 0
    y: 0
    w: 80
    h: 160
    Loaded in 163 ms
    Code:
    /***************************************************
      This is an example sketch for the Adafruit 1.8" SPI display.
      This library works with the Adafruit 1.8" TFT Breakout w/SD card
      ----> http://www.adafruit.com/products/358
      as well as Adafruit raw 1.8" TFT display
      ----> http://www.adafruit.com/products/618
    
      Check out the links above for our tutorials and wiring diagrams
      These displays use SPI to communicate, 4 or 5 pins are required to
      interface (RST is optional)
      Adafruit invests time and resources providing this open source code,
      please support Adafruit and open-source hardware by purchasing
      products from Adafruit!
    
      Written by Limor Fried/Ladyada for Adafruit Industries.
      MIT license, all text above must be included in any redistribution
     ****************************************************/
    
    #include <Adafruit_GFX.h>    // Core graphics library
    #include <Adafruit_ST7735.h> // Hardware-specific library
    #include <SPI.h>
    #include <SD.h>
    
    #if defined(__SAM3X8E__)
        #undef __FlashStringHelper::F(string_literal)
        #define F(string_literal) string_literal
    #endif
    
    // This Teensy3 native optimized version requires specific pins
    //
    #define sclk 14  // SCLK can also use pin 14
    #define mosi 11  // MOSI can also use pin 7
    #define cs   10  // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
    #define dc   9   //  but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
    #define rst  8   // RST can use any pin
    #define sdcs 4   // CS for SD card, can use any pin
    
    Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);
    
    void setup(void) {
      Serial.begin(9600);
    
      // Our supplier changed the 1.8" display slightly after Jan 10, 2012
      // so that the alignment of the TFT had to be shifted by a few pixels
      // this just means the init code is slightly different. Check the
      // color of the tab to see which init code to try. If the display is
      // cut off or has extra 'random' pixels on the top & left, try the
      // other option!
      // If you are seeing red and green color inversion, use Black Tab
    
      // If your TFT's plastic wrap has a Black Tab, use the following:
      //tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab
      // If your TFT's plastic wrap has a Red Tab, use the following:
      tft.initR(INITR_REDTAB);   // initialize a ST7735R chip, red tab
      // If your TFT's plastic wrap has a Green Tab, use the following:
      //tft.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab
    
      Serial.print("Initializing SD card...");
      if (!SD.begin(sdcs)) {
        Serial.println("failed!");
        return;
      }
      Serial.println("OK!");
    
      bmpDraw("test.bmp", 0, 0);
    }
    
    void loop() {
    }
    
    // This function opens a Windows Bitmap (BMP) file and
    // displays it at the given coordinates.  It's sped up
    // by reading many pixels worth of data at a time
    // (rather than pixel by pixel).  Increasing the buffer
    // size takes more of the Arduino's precious RAM but
    // makes loading a little faster.  20 pixels seems a
    // good balance.
    
    #define BUFFPIXEL 20
    
    void bmpDraw(const char *filename, uint8_t x, uint8_t y) {
    
      File     bmpFile;
      int      bmpWidth, bmpHeight;   // W+H in pixels
      uint8_t  bmpDepth;              // Bit depth (currently must be 24)
      uint32_t bmpImageoffset;        // Start of image data in file
      uint32_t rowSize;               // Not always = bmpWidth; may have padding
      uint8_t  sdbuffer[3*BUFFPIXEL]; // pixel buffer (R+G+B per pixel)
      uint8_t  buffidx = sizeof(sdbuffer); // Current position in sdbuffer
      boolean  goodBmp = false;       // Set to true on valid header parse
      boolean  flip    = true;        // BMP is stored bottom-to-top
      int      w, h, row, col;
      uint8_t  r, g, b;
      uint32_t pos = 0, startTime = millis();
    
      if((x >= tft.width()) || (y >= tft.height())) return;
    
      Serial.println();
      Serial.print("Loading image '");
      Serial.print(filename);
      Serial.println('\'');
    
      Serial.print("tft.width(): ");
      Serial.println(tft.width());
      Serial.print("tft.height(): ");
      Serial.println(tft.height());
    
      // Open requested file on SD card
      if ((bmpFile = SD.open(filename)) == false) {
        Serial.print("File not found");
        return;
      }
    
      // Parse BMP header
      if(read16(bmpFile) == 0x4D42) { // BMP signature
        Serial.print("File size: "); Serial.println(read32(bmpFile));
        (void)read32(bmpFile); // Read & ignore creator bytes
        bmpImageoffset = read32(bmpFile); // Start of image data
        Serial.print("Image Offset: "); Serial.println(bmpImageoffset, DEC);
        // Read DIB header
        Serial.print("Header size: "); Serial.println(read32(bmpFile));
        bmpWidth  = read32(bmpFile);
        bmpHeight = read32(bmpFile);
        if(read16(bmpFile) == 1) { // # planes -- must be '1'
          bmpDepth = read16(bmpFile); // bits per pixel
          Serial.print("Bit Depth: "); Serial.println(bmpDepth);
          if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed
    
            goodBmp = true; // Supported BMP format -- proceed!
            Serial.print("Image size: ");
            Serial.print(bmpWidth);
            Serial.print('x');
            Serial.println(bmpHeight);
    
            // BMP rows are padded (if needed) to 4-byte boundary
            rowSize = (bmpWidth * 3 + 3) & ~3;
    
            // If bmpHeight is negative, image is in top-down order.
            // This is not canon but has been observed in the wild.
            if(bmpHeight < 0) {
              bmpHeight = -bmpHeight;
              flip      = false;
            }
    
            // Crop area to be loaded
            w = bmpWidth;
            h = bmpHeight;
            if((x+w-1) >= tft.width())  w = tft.width()  - x;
            if((y+h-1) >= tft.height()) h = tft.height() - y;
    
            Serial.print("x: ");
            Serial.println(x);
            Serial.print("y: ");
            Serial.println(y);
            Serial.print("w: ");
            Serial.println(w);
            Serial.print("h: ");
            Serial.println(h);
    
            // Set TFT address window to clipped image bounds
            tft.setAddrWindow(x, y, x+w-1, y+h-1);
    
            for (row=0; row<h; row++) { // For each scanline...
    
              // Seek to start of scan line.  It might seem labor-
              // intensive to be doing this on every line, but this
              // method covers a lot of gritty details like cropping
              // and scanline padding.  Also, the seek only takes
              // place if the file position actually needs to change
              // (avoids a lot of cluster math in SD library).
              if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
                pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
              else     // Bitmap is stored top-to-bottom
                pos = bmpImageoffset + row * rowSize;
              if(bmpFile.position() != pos) { // Need seek?
                bmpFile.seek(pos);
                buffidx = sizeof(sdbuffer); // Force buffer reload
              }
    
              for (col=0; col<w; col++) { // For each pixel...
                // Time to read more pixel data?
                if (buffidx >= sizeof(sdbuffer)) { // Indeed
                  bmpFile.read(sdbuffer, sizeof(sdbuffer));
                  buffidx = 0; // Set index to beginning
                }
    
                // Convert pixel from BMP to TFT format, push to display
                b = sdbuffer[buffidx++];
                g = sdbuffer[buffidx++];
                r = sdbuffer[buffidx++];
                tft.pushColor(tft.Color565(r,g,b));
              } // end pixel
            } // end scanline
            Serial.print("Loaded in ");
            Serial.print(millis() - startTime);
            Serial.println(" ms");
          } // end goodBmp
        }
      }
    
      bmpFile.close();
      if(!goodBmp) Serial.println("BMP format not recognized.");
    }
    
    // These read 16- and 32-bit types from the SD card file.
    // BMP data is stored little-endian, Arduino is little-endian too.
    // May need to reverse subscript order if porting elsewhere.
    
    uint16_t read16(File f) {
      uint16_t result;
      ((uint8_t *)&result)[0] = f.read(); // LSB
      ((uint8_t *)&result)[1] = f.read(); // MSB
      return result;
    }
    
    uint32_t read32(File f) {
      uint32_t result;
      ((uint8_t *)&result)[0] = f.read(); // LSB
      ((uint8_t *)&result)[1] = f.read();
      ((uint8_t *)&result)[2] = f.read();
      ((uint8_t *)&result)[3] = f.read(); // MSB
      return result;
    }

  11. #11
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,122
    My guess is that you may run into offset issues with lots of graphics... If the board is not initialized properly.

    That is I believe the processor on the display can handle larger display. So part of the init code is setup to specify where the start of memory is and how big. It has been awhile since I played with some of these.

  12. #12
    Junior Member
    Join Date
    May 2018
    Posts
    6
    Yeah, I agree that's definitely a concern.

    I think what I need to do is diff the teensy version against the newer version that's in the github repo and see what the differences are. The github version supposedly supports this small screen, but probably doesn't have the teensy-specific optimizations (just a guess). I think it'd be awesome if the teensy performance enhancement changes made it into the mainline, instead of the teensy folks maintaining an older/patched version of the code. I'll poke around with it more in the next few days. I think at this point, my best bet is to try and get the official version from adafruit working without teensyduino patches and then see if I can port the patches to the new version. Either way, I think what's in teensyduino probably needs an update.

  13. #13
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,768
    Quote Originally Posted by randomfish View Post
    Yeah, I agree that's definitely a concern.

    I think what I need to do is diff the teensy version against the newer version that's in the github repo and see what the differences are. The github version supposedly supports this small screen, but probably doesn't have the teensy-specific optimizations (just a guess). I think it'd be awesome if the teensy performance enhancement changes made it into the mainline, instead of the teensy folks maintaining an older/patched version of the code. I'll poke around with it more in the next few days. I think at this point, my best bet is to try and get the official version from adafruit working without teensyduino patches and then see if I can port the patches to the new version. Either way, I think what's in teensyduino probably needs an update.
    The Adafruit version has the following that the Teensy version does not:
    • The Adafruit has support for the 128x128 pixel display in addition to the 128x160 display.
    • It also has support for the ESP8266 microprocessor that is not in the Teensy version.
    • You can omit the RTS option to the constructor, and it will default to -1.
    • Color555 is an inline function in Teensy, and an external function in Adafruit.


    And the Teensy has:
    • Explicit support for the various Teensy models.
    • Support for SPI transactions.

  14. #14
    I am trying to do the same as the OP. I am getting an error message "unable to read file "parrot.bmp".I am using a teensy 3.2 wired up exactly as the OP and I used the st7735_t3 exampla library. The graphics test works fine and the speedtest is incredibly fast.But the spitftbitmap test just gives me the error message.Not sure what the problem is?

  15. #15
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,559
    Quote Originally Posted by darebyvet View Post
    I am trying to do the same as the OP. I am getting an error message "unable to read file "parrot.bmp".I am using a teensy 3.2 wired up exactly as the OP and I used the st7735_t3 exampla library. The graphics test works fine and the speedtest is incredibly fast.But the spitftbitmap test just gives me the error message.Not sure what the problem is?
    you need to copy parrot.bmp from the library folder arduino-1.8.12/hardware/teensy/avr/libraries/ST7735_t3/parrot.bmp to a microSD card and then insert the microSD in the slot on the backside of ST7735
    Last edited by manitou; 06-29-2020 at 11:10 AM.

  16. #16
    I already have the parrot.bmp file loaded onto a microSD card and it is inserted into the tft.I am testing the bmp upload speed for different microcontrollers .it works fine with an arduino UNO and the graphicstest works fine with the teensy 3.2 , but the spitftbitmap doesnt work with the teensy.Is the parrot.bmp in the ST7735_t3 different than then one on the adafruit website? it seems odd I would need to upload a different .bmp.

  17. #17
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,559
    works for me on T3.2 1.8.12/1.53-beta2, parrot image displays and serial monitor says
    Code:
    Initializing SD card...OK!
    
    Loading image 'parrot.bmp'
    File size: 61496
    Image Offset: 54
    Header size: 40
    Bit Depth: 24
    Image size: 128x160
    Loaded in 128 ms
    Your error message sounds like it is not even finding parrot.bmp. Maybe run SD lib example CardInfo to view files on microSD on the display PCB.

  18. #18
    OK thanks.I will check my wiring.

  19. #19
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,278
    Quote Originally Posted by darebyvet View Post
    Is the parrot.bmp in the ST7735_t3 different than then one on the adafruit website?
    I downloaded parrot.bmp from this Adafruit page. It's the exact same file as found in the ST7735_t3 library. I used the Linux "cmp" utility to confirm they are the exact same data.

  20. #20
    OK thanks so it mmust be a wiring error on my part then.I will check the pins

  21. #21
    oh this is driving me nuts.Can some help by showing me the pin connections for this sketch.I cant figure out what I am doing wrong.I keep geting the unable to access sd card error.The file is fine>I can load it onto the tft using an arduino uno with the spitfitbmp sketch. I am unsure where to put the DC pin.I can wire it up and the graphics test works, but I catn get the spitftbmp to work.

  22. #22
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,559
    Quote Originally Posted by darebyvet View Post
    oh this is driving me nuts.Can some help by showing me the pin connections for this sketch.I cant figure out what I am doing wrong.I keep geting the unable to access sd card error.The file is fine>I can load it onto the tft using an arduino uno with the spitfitbmp sketch. I am unsure where to put the DC pin.I can wire it up and the graphics test works, but I catn get the spitftbmp to work.
    Code:
           LITE MISO SCK MOSI CS SD-CS D/C Reset Vcc GND
            3v3  12   13  11  10   4    9    8   3v3 gnd
    using https://www.adafruit.com/product/358 and Teensy lib ST7735_t3 (make sure you don't have another copy in your libraries/ folder)
    Last edited by manitou; 06-30-2020 at 05:24 AM.

  23. #23
    Senior Member
    Join Date
    May 2017
    Posts
    102
    Hello,

    try to add 10k pullup resitors on both CS lines.

  24. #24
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,278
    Did you run the SD library's CardInfo example? What did it print?

  25. #25
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,122
    Or maybe an incompatible file format on the SDCard? I don't remember if this library came with it's own example formatter program, I believe SDFat does...

Posting Permissions

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