Teensy 3.6 ST7735 Example does not Compile

Status
Not open for further replies.
I'm new to the Teensy ecosystem and have just received my new 3.5 and 3.6. I've installed the necessary files and can run and modify the blink sketch. I have a TFT program which runs on UNO, Mega and Due but nothing happens on the screen when installed on Teensy 3.6. I decided to run the ST7735 example from the Teensy installed libraries but it won't compile. It does compile for UNO. I get the following errors:



graphicstest: In function 'void setup()':
graphicstest:100: warning: deprecated conversion from string constant to 'char*'
testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST7735_WHITE);

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp: In member function 'void Adafruit_GFX::drawChar(int16_t, int16_t, unsigned char, uint16_t, uint16_t, uint8_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp:566:14: warning: unused variable 'xa' [-Wunused-variable]

xa = pgm_read_byte(&glyph->xAdvance);

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp: In member function 'void Adafruit_GFX::drawBitmap(int16_t, int16_t, const uint8_t*, int16_t, int16_t, uint16_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp:392:27: warning: 'byte' may be used uninitialized in this function [-Wmaybe-uninitialized]

if(i & 7) byte <<= 1;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp: In member function 'void Adafruit_GFX::drawBitmap(int16_t, int16_t, const uint8_t*, int16_t, int16_t, uint16_t, uint16_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp:410:27: warning: 'byte' may be used uninitialized in this function [-Wmaybe-uninitialized]

if(i & 7) byte <<= 1;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp: In member function 'void Adafruit_GFX::drawBitmap(int16_t, int16_t, uint8_t*, int16_t, int16_t, uint16_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp:427:27: warning: 'byte' may be used uninitialized in this function [-Wmaybe-uninitialized]

if(i & 7) byte <<= 1;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp: In member function 'void Adafruit_GFX::drawBitmap(int16_t, int16_t, uint8_t*, int16_t, int16_t, uint16_t, uint16_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp:443:27: warning: 'byte' may be used uninitialized in this function [-Wmaybe-uninitialized]

if(i & 7) byte <<= 1;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp: In member function 'void Adafruit_GFX::drawXBitmap(int16_t, int16_t, const uint8_t*, int16_t, int16_t, uint16_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp:462:27: warning: 'byte' may be used uninitialized in this function [-Wmaybe-uninitialized]

if(i & 7) byte >>= 1;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp: In member function 'void Adafruit_GFX::drawChar(int16_t, int16_t, unsigned char, uint16_t, uint16_t, uint8_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp:600:9: warning: 'bits' may be used uninitialized in this function [-Wmaybe-uninitialized]

if(bits & 0x80) {

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp:604:47: warning: 'yo16' may be used uninitialized in this function [-Wmaybe-uninitialized]

fillRect(x+(xo16+xx)*size, y+(yo16+yy)*size, size, size, color);

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX\Adafruit_GFX.cpp:570:14: warning: 'xo16' may be used uninitialized in this function [-Wmaybe-uninitialized]

int16_t xo16, yo16;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp: In constructor 'Adafruit_ST7735::Adafruit_ST7735(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:30:2: error: '_cs' was not declared in this scope

_cs = cs;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:31:2: error: '_rs' was not declared in this scope

_rs = rs;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:32:2: error: '_sid' was not declared in this scope

_sid = sid;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:33:2: error: '_sclk' was not declared in this scope

_sclk = sclk;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:34:2: error: '_rst' was not declared in this scope

_rst = rst;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp: In constructor 'Adafruit_ST7735::Adafruit_ST7735(uint8_t, uint8_t, uint8_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:43:2: error: '_cs' was not declared in this scope

_cs = cs;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:44:2: error: '_rs' was not declared in this scope

_rs = rs;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:45:2: error: '_rst' was not declared in this scope

_rst = rst;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:47:2: error: '_sid' was not declared in this scope

_sid = _sclk = (uint8_t)-1;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:47:10: error: '_sclk' was not declared in this scope

_sid = _sclk = (uint8_t)-1;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp: In member function 'void Adafruit_ST7735::commonInit(const uint8_t*)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:518:2: error: 'colstart' was not declared in this scope

colstart = rowstart = 0; // May be overridden in init func

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:518:14: error: 'rowstart' was not declared in this scope

colstart = rowstart = 0; // May be overridden in init func

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:675:6: error: '_rst' was not declared in this scope

if (_rst) {

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp: In member function 'void Adafruit_ST7735::initR(uint8_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:702:3: error: 'colstart' was not declared in this scope

colstart = 2;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:703:3: error: 'rowstart' was not declared in this scope

rowstart = 1;

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp: In member function 'void Adafruit_ST7735::setAddrWindow(uint8_t, uint8_t, uint8_t, uint8_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:723:17: error: 'colstart' was not declared in this scope

writedata16(x0+colstart); // XSTART

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:726:17: error: 'rowstart' was not declared in this scope

writedata16(y0+rowstart); // YSTART

^

Multiple libraries were found for "Adafruit_GFX.h"
Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_GFX
Not used: C:\Program Files (x86)\Arduino\libraries\Adafruit_GFX
Multiple libraries were found for "Adafruit_ST7735.h"
Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Adafruit_ST7735
Not used: C:\Users\Hersh\Desktop\Documents\Arduino\libraries\Adafruit-ST7735
Multiple libraries were found for "SPI.h"
Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI
Not used: C:\Program Files (x86)\Arduino\libraries\SPI
Error compiling for board Teensy 3.6.


What am I missing? Please help.


Thanks Hersh
 
Looks like this one has not been updated for T3.5/3.6...

I did a quick edit, basically just needed to add the hardware device names to header and source file for the two new chips to some #if or #elif statements.

I have included the updates below in zip file.

Try replacing the two files where Teensyduino installed them. On my machine that is at:
C:\arduino-1.6.12\hardware\teensy\avr\libraries\Adafruit_ST7735

But again that depends on where you installed your version of Arduino.

Will try to setup to do pull request to update for next build
 

Attachments

  • Adafruit_ST7735.zip
    7.9 KB · Views: 385
Edit: Paul, not sure how to do Pull request as I am forked from the Adafruit git.... Not sure how to do multiple master versions here...
 

Paul, I think you probably need to change line 575 of Adafruit_ST7735.cpp from:

Code:
#elif defined(__MK20DX128__) || defined(__MK20DX256__)

to:

Code:
#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)

Or else provide Teensy 3.5/3.6 versions of the SPI init code.

I'm attempting to add in the support for the 128x128 displays (INITR_144GREENTAB) that is needed for the uncanny eyes program (https://learn.adafruit.com/animated-electronic-eyes-using-teensy-3-1), but I need to change my DC pin to one of the supported CS pins, which means rewiring the protoboard that I've set up. So I can't test it for a bit, but here is my patch to add INITR_144GREENTAB support:

Code:
Index: Adafruit_ST7735.cpp
===================================================================
--- Adafruit_ST7735.cpp (revision 61)
+++ Adafruit_ST7735.cpp (working copy)
@@ -1,10 +1,15 @@
-/*************************************************** 
+/***************************************************
   This is a library for the Adafruit 1.8" SPI display.
-  This library works with the Adafruit 1.8" TFT Breakout w/SD card
+
+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
+The 1.8" TFT shield
+  ----> https://www.adafruit.com/product/802
+The 1.44" TFT breakout
+  ----> https://www.adafruit.com/product/2088
+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)
@@ -25,7 +30,7 @@
 
 // Constructor when using software SPI.  All output pins are configurable.
 Adafruit_ST7735::Adafruit_ST7735(uint8_t cs, uint8_t rs, uint8_t sid,
- uint8_t sclk, uint8_t rst) : Adafruit_GFX(ST7735_TFTWIDTH, ST7735_TFTHEIGHT)
+ uint8_t sclk, uint8_t rst) : Adafruit_GFX(ST7735_TFTWIDTH, ST7735_TFTHEIGHT_18)
 {
        _cs   = cs;
        _rs   = rs;
@@ -39,7 +44,7 @@
 // Constructor when using hardware SPI.  Faster, but must use SPI pins
 // specific to each board type (e.g. 11,13 for Uno, 51,52 for Mega, etc.)
 Adafruit_ST7735::Adafruit_ST7735(uint8_t cs, uint8_t rs, uint8_t rst) :
-  Adafruit_GFX(ST7735_TFTWIDTH, ST7735_TFTHEIGHT) {
+  Adafruit_GFX(ST7735_TFTWIDTH, ST7735_TFTHEIGHT_18) {
        _cs   = cs;
        _rs   = rs;
        _rst  = rst;
@@ -233,6 +238,8 @@
        if (pin == 2 || pin == 6 || pin == 9) return true;
        if (pin == 10 || pin == 15) return true;
        if (pin >= 20 && pin <= 23) return true;
+       Serial.print ("spi_pin_is_cs failed, ");
+       Serial.println (pin);
        return false;
 }
 
@@ -249,6 +256,8 @@
                 case 22: CORE_PIN22_CONFIG = PORT_PCR_MUX(2); return 0x08; // PTC1
                 case 15: CORE_PIN15_CONFIG = PORT_PCR_MUX(2); return 0x10; // PTC0
         }
+       Serial.print ("spi_configure_cs_pin failed, ");
+       Serial.println (pin);
         return 0;
 }
 
@@ -467,6 +476,15 @@
       0x00, 0x00,             //     XSTART = 0
       0x00, 0x9F },           //     XEND = 159
 
+  Rcmd2green144[] = {              // Init for 7735R, part 2 (green 1.44 tab)
+    2,                        //  2 commands in list:
+    ST7735_CASET  , 4      ,  //  1: Column addr set, 4 args, no delay:
+      0x00, 0x00,             //     XSTART = 0
+      0x00, 0x7F,             //     XEND = 127
+    ST7735_RASET  , 4      ,  //  2: Row addr set, 4 args, no delay:
+      0x00, 0x00,             //     XSTART = 0
+      0x00, 0x7F },           //     XEND = 127
+
   Rcmd3[] = {                 // Init for 7735R, part 3 (red or green tab)
     4,                        //  4 commands in list:
     ST7735_GMCTRP1, 16      , //  1: Magical unicorn dust, 16 args, no delay:
@@ -572,7 +590,7 @@
        csport ->PIO_CODR  |=  cspinmask; // Set control bits to LOW (idle)
 
 
-#elif defined(__MK20DX128__) || defined(__MK20DX256__) 
+#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
        if (_sid == (uint8_t)-1) _sid = 11;
        if (_sclk == (uint8_t)-1) _sclk = 13;
        if ( spi_pin_is_cs(_cs) && spi_pin_is_cs(_rs)
@@ -701,6 +719,11 @@
                commandList(Rcmd2green);
                colstart = 2;
                rowstart = 1;
+       } else if(options == INITR_144GREENTAB) {
+               _height = ST7735_TFTHEIGHT_144;
+               commandList(Rcmd2green144);
+               colstart = 2;
+               rowstart = 3;
        } else {
                // colstart, rowstart left at default '0' values
                commandList(Rcmd2red);
@@ -811,7 +834,12 @@
                        writedata(MADCTL_MX | MADCTL_MY | MADCTL_BGR);
                }
                _width  = ST7735_TFTWIDTH;
-               _height = ST7735_TFTHEIGHT;
+
+               if (tabcolor == INITR_144GREENTAB) 
+                 _height = ST7735_TFTHEIGHT_144;
+               else
+                 _height = ST7735_TFTHEIGHT_18;
+
                break;
        case 1:
                if (tabcolor == INITR_BLACKTAB) {
@@ -819,7 +847,12 @@
                } else {
                        writedata(MADCTL_MY | MADCTL_MV | MADCTL_BGR);
                }
-               _width  = ST7735_TFTHEIGHT;
+
+               if (tabcolor == INITR_144GREENTAB) 
+                 _width = ST7735_TFTHEIGHT_144;
+               else
+                 _width = ST7735_TFTHEIGHT_18;
+
                _height = ST7735_TFTWIDTH;
                break;
        case 2:
@@ -829,7 +862,11 @@
                        writedata(MADCTL_BGR);
                }
                _width  = ST7735_TFTWIDTH;
-               _height = ST7735_TFTHEIGHT;
+               if (tabcolor == INITR_144GREENTAB) 
+                 _height = ST7735_TFTHEIGHT_144;
+               else
+                 _height = ST7735_TFTHEIGHT_18;
+
                break;
        case 3:
                if (tabcolor == INITR_BLACKTAB) {
@@ -837,7 +874,11 @@
                } else {
                        writedata(MADCTL_MX | MADCTL_MV | MADCTL_BGR);
                }
-               _width  = ST7735_TFTHEIGHT;
+               if (tabcolor == INITR_144GREENTAB) 
+                 _width = ST7735_TFTHEIGHT_144;
+               else
+                 _width = ST7735_TFTHEIGHT_18;
+
                _height = ST7735_TFTWIDTH;
                break;
        }
Index: Adafruit_ST7735.h
===================================================================
--- Adafruit_ST7735.h   (revision 61)
+++ Adafruit_ST7735.h   (working copy)
@@ -1,10 +1,15 @@
 /***************************************************
   This is a library for the Adafruit 1.8" SPI display.
-  This library works with the Adafruit 1.8" TFT Breakout w/SD card
+
+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
+The 1.8" TFT shield
+  ----> https://www.adafruit.com/product/802
+The 1.44" TFT breakout
+  ----> https://www.adafruit.com/product/2088
+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)
@@ -44,8 +49,16 @@
 #define INITR_REDTAB   0x1
 #define INITR_BLACKTAB   0x2
 
+#define INITR_18GREENTAB    INITR_GREENTAB
+#define INITR_18REDTAB      INITR_REDTAB
+#define INITR_18BLACKTAB    INITR_BLACKTAB
+#define INITR_144GREENTAB   0x1
+
 #define ST7735_TFTWIDTH  128
-#define ST7735_TFTHEIGHT 160
+// for 1.44" display
+#define ST7735_TFTHEIGHT_144 128
+// for 1.8" display
+#define ST7735_TFTHEIGHT_18  160
 
 #define ST7735_NOP     0x00
 #define ST7735_SWRESET 0x01
@@ -100,7 +113,7 @@
 #define        ST7735_GREEN   0x07E0
 #define ST7735_CYAN    0x07FF
 #define ST7735_MAGENTA 0xF81F
-#define ST7735_YELLOW  0xFFE0  
+#define ST7735_YELLOW  0xFFE0
 #define ST7735_WHITE   0xFFFF
 
I am trying to use the Adafruit 358 with a Teensy 3.6. I have used the files supplied by KurtE in Jan 14. If I specify an Arduino Uno as the board it compiles correctly. However with the Teensy 3.6 specified I get a whole raft of compilation errors. What am I doing wrong please?
 
I am trying to use the Adafruit 358 with a Teensy 3.6. I have used the files supplied by KurtE in Jan 14. If I specify an Arduino Uno as the board it compiles correctly. However with the Teensy 3.6 specified I get a whole raft of compilation errors. What am I doing wrong please?

Seems like this is a different device - creating a new thread with more details would allow assistance: IDE version, TeensyDuino version - links to the hardware Adafruit #358 and perhaps the code, and most importantly Post the verbose console output of the compilation errors.
 
Status
Not open for further replies.
Back
Top