Teensyduino 1.31 Beta #2 Available

Status
Not open for further replies.

Paul

Administrator
Staff member
Here is a second beta test for Teensyduino 1.31.


Edit: old beta test linkes removed. Full non-beta release is here:
http://www.pjrc.com/teensy/td_download.html



Changes since Teensyduino 1.31-beta1:

  • Arduino SD library support 4 bit SDIO on Teensy 3.5 & 3.6 (special thanks WMXZ)
  • Fix EEPROM on Teensy 3.6 with CPU speed > 120 MHz (special thanks Defragster)
  • Update FlexCAN library for CAN1 on Teensy 3.6 (thanks Pawelsky)
  • Update OctoWS2811 to support Teensy 3.5 & 3.6
  • Fix USB serial number on Teensy 3.6 with CPU speed > 120 MHz
  • Fix audio I2S output on Teensy 3.6 with CPU speed > 120 MHz when also using I2S input
  • Support Teensy 3.5 & 3.6 on older versons of Arduino
  • Fix SPI1 default SCK1 pin (thanks KurtE)
  • Optimize attachInterrupt (thanks tni)
  • Improve USB stability on Teensy 3.6 with CPU 180 or 216 MHz
  • Add USB MIDI custom name example
  • Fix Adafruit_ST7735 on Teensy 3.5 & 3.6 (thanks MichaelMeissner)
  • Many library metadata files updated for PlatformIO
 
Before everyone posts it... Yeah, I see the annoying (but harmless) compiler warnings from the HSRUN functions with Teensy 3.2. Will fix soon...
 
Just tried the SD Card Info example from "https://github.com/PaulStoffregen/SD/blob/master/examples/CardInfo/CardInfo.ino" with 1.31 Beta 2.

Am I right in thinking that this example should work now with a standard T3.6 using the built-in SD card? I changed the "chipselect" as follows...

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
// Teensy audio board: pin 10
// Teensy 3.5 & 3.6 on-board: BUILTIN_SDCARD
// Wiz820+SD board: pin 4
// Teensy 2.0: pin 0
// Teensy++ 2.0: pin 20
const int chipSelect = BUILTIN_SDCARD;

I'm getting the following error messages on trying to compile...

Code:
Arduino: 1.6.11 (Windows 7), TD: 1.31-beta2, Board: "Teensy 3.6, Serial, 180 MHz, United Kingdom"

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:25:57: error: 'void (* SdFile::dateTime_)(uint16_t*, uint16_t*)' is not a static member of 'class SdFile'

 void (*SdFile::dateTime_)(uint16_t* date, uint16_t* time) = NULL;

                                                         ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:33:28: error: no 'uint8_t SdFile::addCluster()' member function declared in class 'SdFile'

 uint8_t SdFile::addCluster() {

                            ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:46:35: error: no 'uint8_t SdFile::addDirCluster()' member function declared in class 'SdFile'

 uint8_t SdFile::addDirCluster(void) {

                                   ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:61:44: error: no 'dir_t* SdFile::cacheDirEntry(uint8_t)' member function declared in class 'SdFile'

 dir_t* SdFile::cacheDirEntry(uint8_t action) {

                                            ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:74:27: error: no 'uint8_t SdFile::close()' member function declared in class 'SdFile'

 uint8_t SdFile::close(void) {

                           ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:91:71: error: no 'uint8_t SdFile::contiguousRange(uint32_t*, uint32_t*)' member function declared in class 'SdFile'

 uint8_t SdFile::contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock) {

                                                                       ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:130:44: error: no 'uint8_t SdFile::createContiguous(SdFile*, const char*, uint32_t)' member function declared in class 'SdFile'

         const char* fileName, uint32_t size) {

                                            ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:158:36: error: no 'uint8_t SdFile::dirEntry(dir_t*)' member function declared in class 'SdFile'

 uint8_t SdFile::dirEntry(dir_t* dir) {

                                    ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:178:50: error: no 'void SdFile::dirName(const dir_t&, char*)' member function declared in class 'SdFile'

 void SdFile::dirName(const dir_t& dir, char* name) {

                                                  ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:201:46: error: no 'void SdFile::ls(uint8_t, uint8_t)' member function declared in class 'SdFile'

 void SdFile::ls(uint8_t flags, uint8_t indent) {

                                              ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:245:58: error: no 'uint8_t SdFile::make83Name(const char*, uint8_t*)' member function declared in class 'SdFile'

 uint8_t SdFile::make83Name(const char* str, uint8_t* name) {

                                                          ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:284:57: error: no 'uint8_t SdFile::makeDir(SdFile*, const char*)' member function declared in class 'SdFile'

 uint8_t SdFile::makeDir(SdFile* dir, const char* dirName) {

                                                         ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:384:74: error: no 'uint8_t SdFile::open(SdFile*, const char*, uint8_t)' member function declared in class 'SdFile'

 uint8_t SdFile::open(SdFile* dirFile, const char* fileName, uint8_t oflag) {

                                                                          ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:476:68: error: no 'uint8_t SdFile::open(SdFile*, uint16_t, uint8_t)' member function declared in class 'SdFile'

 uint8_t SdFile::open(SdFile* dirFile, uint16_t index, uint8_t oflag) {

                                                                    ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:502:64: error: no 'uint8_t SdFile::openCachedEntry(uint8_t, uint8_t)' member function declared in class 'SdFile'

 uint8_t SdFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) {

                                                                ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:550:26: error: 'uint8_t SdFile::openRoot' is not a static member of 'class SdFile'

 uint8_t SdFile::openRoot(SdVolume* vol) {

                          ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:550:26: error: 'SdVolume' was not declared in this scope

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:550:36: error: 'vol' was not declared in this scope

 uint8_t SdFile::openRoot(SdVolume* vol) {

                                    ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:550:41: error: expected ',' or ';' before '{' token

 uint8_t SdFile::openRoot(SdVolume* vol) {

                                         ^

Multiple libraries were found for "SD.h"
 Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
 Not used: C:\Program Files (x86)\Arduino\libraries\SD
Error compiling for board Teensy 3.6.
 
Unfortunately, the Adafruit_ST7735 library just does not work for me, using the 128x128 TFT display I've been using for uncannyEyes.

I cloned the graphicstest and changed the pin defaults for my screen:
  • CS is pin 10
  • D/C is pin A1/15
  • Reset is pin 8
  • SCLK is pin 13
  • MOSI is pin 11
  • I used the INITR_GREENTAB initialization option (note in the Adafruit version, INITR_128GREENTAB is the preferred version, but that isn't in the Teensy version).
  • screen powered via 3.3v regulator off of VIN
  • Teensy 3.1

If I substitute the current Adafruit library for the Teensy one it works fine (part of the screen is clipped because the 128x128 screen is smaller than the 160x128 display, but the rest of the stuff is displayed on the screen).

If I use the current 1.31 beta2 Teensy version, the screen just stays blank.

Note, this is a Teensy 3.1, and not the Teensy 3.6, so the recent changes should not matter. Unlike uncannyEyes, this test just uses the standard graphics primitives.

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
 ****************************************************/

// This Teensy3 native optimized version requires specific pins
//
#define sclk 13  // 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   A1  //  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

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#if defined(__SAM3X8E__)
    #undef __FlashStringHelper::F(string_literal)
    #define F(string_literal) string_literal
#endif

// Option 1: use any pins but a little slower
//Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);

// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);
float p = 3.1415926;

 
#define Neutral 0
#define Press 1
#define Up 2
#define Down 3
#define Right 4
#define Left 5
 
// Check the joystick position
int CheckJoystick()
{
  int joystickState = analogRead(3);
  
  if (joystickState < 50) return Left;
  if (joystickState < 150) return Down;
  if (joystickState < 250) return Press;
  if (joystickState < 500) return Right;
  if (joystickState < 650) return Up;
  return Neutral;
}


void setup(void) {
  pinMode(sdcs, INPUT_PULLUP);  // don't touch the SD card
  Serial.begin(9600);
  Serial.print("hello!");

  // 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

  //tft.initR(INITR_144GREENTAB); // initialize a ST7735R chip with 128x128 display, green tab
  tft.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab

  Serial.println("init");

  uint16_t time = millis();
  tft.fillScreen(ST7735_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);

  // large block of text
  tft.fillScreen(ST7735_BLACK);
  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);
  delay(1000);

  // tft print function!
  tftPrintTest();
  delay(4000);

  // a single pixel
  tft.drawPixel(tft.width()/2, tft.height()/2, ST7735_GREEN);
  delay(500);

  // line draw test
  testlines(ST7735_YELLOW);
  delay(500);

  // optimized lines
  testfastlines(ST7735_RED, ST7735_BLUE);
  delay(500);

  testdrawrects(ST7735_GREEN);
  delay(500);

  testfillrects(ST7735_YELLOW, ST7735_MAGENTA);
  delay(500);

  tft.fillScreen(ST7735_BLACK);
  testfillcircles(10, ST7735_BLUE);
  testdrawcircles(10, ST7735_WHITE);
  delay(500);

  testroundrects();
  delay(500);

  testtriangles();
  delay(500);

  mediabuttons();
  delay(500);

  Serial.println("done");
  delay(1000);
}

void loop() {
  tft.invertDisplay(true);
  delay(500);
  tft.invertDisplay(false);
  delay(500);
  int joy = CheckJoystick();
  switch (joy)
  {
    case Left:
      Serial.println("Left");
      break;
    case Right:
      Serial.println("Right");
      break;
    case Up:
      Serial.println("Up");
      break;
    case Down:
      Serial.println("Down");
      break;
    case Press:
      Serial.println("Press");
      break;
  }
}

void testlines(uint16_t color) {
  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(0, 0, x, tft.height()-1, color);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(0, 0, tft.width()-1, y, color);
  }

  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(tft.width()-1, 0, 0, y, color);
  }

  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(0, tft.height()-1, x, 0, color);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(0, tft.height()-1, tft.width()-1, y, color);
  }

  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color);
  }
}

void testdrawtext(char *text, uint16_t color) {
  tft.setCursor(0, 0);
  tft.setTextColor(color);
  tft.setTextWrap(true);
  tft.print(text);
}

void testfastlines(uint16_t color1, uint16_t color2) {
  tft.fillScreen(ST7735_BLACK);
  for (int16_t y=0; y < tft.height(); y+=5) {
    tft.drawFastHLine(0, y, tft.width(), color1);
  }
  for (int16_t x=0; x < tft.width(); x+=5) {
    tft.drawFastVLine(x, 0, tft.height(), color2);
  }
}

void testdrawrects(uint16_t color) {
  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color);
  }
}

void testfillrects(uint16_t color1, uint16_t color2) {
  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=tft.width()-1; x > 6; x-=6) {
    tft.fillRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color1);
    tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color2);
  }
}

void testfillcircles(uint8_t radius, uint16_t color) {
  for (int16_t x=radius; x < tft.width(); x+=radius*2) {
    for (int16_t y=radius; y < tft.height(); y+=radius*2) {
      tft.fillCircle(x, y, radius, color);
    }
  }
}

void testdrawcircles(uint8_t radius, uint16_t color) {
  for (int16_t x=0; x < tft.width()+radius; x+=radius*2) {
    for (int16_t y=0; y < tft.height()+radius; y+=radius*2) {
      tft.drawCircle(x, y, radius, color);
    }
  }
}

void testtriangles() {
  tft.fillScreen(ST7735_BLACK);
  int color = 0xF800;
  int t;
  int w = 63;
  int x = 159;
  int y = 0;
  int z = 127;
  for(t = 0 ; t <= 15; t+=1) {
    tft.drawTriangle(w, y, y, x, z, x, color);
    x-=4;
    y+=4;
    z-=4;
    color+=100;
  }
}

void testroundrects() {
  tft.fillScreen(ST7735_BLACK);
  int color = 100;
  int i;
  int t;
  for(t = 0 ; t <= 4; t+=1) {
    int x = 0;
    int y = 0;
    int w = 127;
    int h = 159;
    for(i = 0 ; i <= 24; i+=1) {
      tft.drawRoundRect(x, y, w, h, 5, color);
      x+=2;
      y+=3;
      w-=4;
      h-=6;
      color+=1100;
    }
    color+=100;
  }
}

void tftPrintTest() {
  tft.setTextWrap(false);
  tft.fillScreen(ST7735_BLACK);
  tft.setCursor(0, 30);
  tft.setTextColor(ST7735_RED);
  tft.setTextSize(1);
  tft.println("Hello World!");
  tft.setTextColor(ST7735_YELLOW);
  tft.setTextSize(2);
  tft.println("Hello World!");
  tft.setTextColor(ST7735_GREEN);
  tft.setTextSize(3);
  tft.println("Hello World!");
  tft.setTextColor(ST7735_BLUE);
  tft.setTextSize(4);
  tft.print(1234.567);
  delay(1500);
  tft.setCursor(0, 0);
  tft.fillScreen(ST7735_BLACK);
  tft.setTextColor(ST7735_WHITE);
  tft.setTextSize(0);
  tft.println("Hello World!");
  tft.setTextSize(1);
  tft.setTextColor(ST7735_GREEN);
  tft.print(p, 6);
  tft.println(" Want pi?");
  tft.println(" ");
  tft.print(8675309, HEX); // print 8,675,309 out in HEX!
  tft.println(" Print HEX!");
  tft.println(" ");
  tft.setTextColor(ST7735_WHITE);
  tft.println("Sketch has been");
  tft.println("running for: ");
  tft.setTextColor(ST7735_MAGENTA);
  tft.print(millis() / 1000);
  tft.setTextColor(ST7735_WHITE);
  tft.print(" seconds.");
}

void mediabuttons() {
  // play
  tft.fillScreen(ST7735_BLACK);
  tft.fillRoundRect(25, 10, 78, 60, 8, ST7735_WHITE);
  tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_RED);
  delay(500);
  // pause
  tft.fillRoundRect(25, 90, 78, 60, 8, ST7735_WHITE);
  tft.fillRoundRect(39, 98, 20, 45, 5, ST7735_GREEN);
  tft.fillRoundRect(69, 98, 20, 45, 5, ST7735_GREEN);
  delay(500);
  // play color
  tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_BLUE);
  delay(50);
  // pause color
  tft.fillRoundRect(39, 98, 20, 45, 5, ST7735_RED);
  tft.fillRoundRect(69, 98, 20, 45, 5, ST7735_RED);
  // play color
  tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_GREEN);
}

<edit>
I was curious, I went back to previous Teensy versions back to 1.26, and none of them seem to work with the teensy version of Adafruit_ST7735 using the INITR_GREENTAB option.]

So for now, I'm going to keep the Adafruit version in my tree instead of the Teensy version. For me, the work around is acceptable, but presumably there might be other people trying to use this display.
 
Last edited:
it may be necessary to remove any SdFat libraries that you have

Looking at the IDE library list (menu "Sketch" then "Include Library"), I see there is "SD" (under Arduino Libraries) and "SdFat" (under "Contributed Libraries") and also "uSDFS" (under "Contributed Libraries"). I think I remember adding these last two when experimenting with the SD card previously.

So your suggestion implies removing just the second one ("SdFat"). There is no obvious way to remove a library from the IDE menu, so I went to delete the folder called "SdFat" listed in "C:\Program Files (x86)\Arduino\libraries".

This then compiled without error. Thanks for your help.
 
Last edited:
It compiles for me, without errors, too,
BUT:

The example "SdCardTest" from the AudioLibrary does not work. This is the output:
Code:
SD Card Test ------------
 SD card is connected :-)
 Card type is SDHC
 File system space is 7939.82 Mbytes.
 SD library can not access the filesystem!
 Please report this problem, with the make & model of your SD card.
   http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
 Unable to find SDTEST1.WAV on this card
I should mention, that SDTEST1.WAV is on the card.
 
Before everyone posts it... Yeah, I see the annoying (but harmless) compiler warnings from the HSRUN functions with Teensy 3.2. Will fix soon...

Bummer - I could have caught those - but ... it was late when published and I'm just now seeing this was posted . . .

Paul: for your make the IDE Better list - would it be possible on the 'status' BAR between the Code/Output windows to place a count of Warnings / Errors?
 
...and add a VT-100 emulation PLEEAAAAAAAAASE :rolleyes:
(+ my little trick with "defs.h" in platform.txt :)
 
Last edited:
I have the same problem with the new ST7735 as Michael has reported - I am using a T3.6 and just get a blank, black screen. When I revert to the previous library I was using all is well. I'll compare the two libraries and try to sort out what's wrong.

Pete
 
It compiles for me, without errors, too,
BUT:

The example "SdCardTest" from the AudioLibrary does not work. This is the output:
[
I should mention, that SDTEST1.WAV is on the card.

Did you use BUILTIN_SDCARD in the SD.begin()?
 
@manitou. Yes. See the quoted output - everything is ok, except accessing the file. In the example.
Other sketches work, but not the one example from the audio-library.

A Question, i never tried this: Is it possible to open a file twice ? I'd like to try something like a big FIFO-Buffer.. on SD-Card
 
Last edited:
@manitou. Yes. See the quoted output - everything is ok, except accessing the file. In the example.
Other sketches work, but not the one example from the audio-library.

Yes, your output suggests BUILTIN_SDCARD was used in init() but not begin()
 
Hello, I'm new to this forum and I sure could use a little help.

I,m building the adafruit "uncannyEyes" project for halloween.
I have a new Teensy3.2 and a pair of 1.8 TFTs <128*160 ST7735 driver chip>
I,m running arduino IDE version 1.6.12 and the above mentioned beta version of teensyduino .
Should i roll back my verion of arduino IDE or go ahead and try it with the beta version.
It sounds like their may be a few quirks ?

Thanks, CJ
 
Which display are you using? My ST7735 is 160x128 pixels.

It is a 128x128 display that I bought from ebay: http://www.ebay.com/itm/122005165823?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT.

Adafruit sells a similar display that also has a micro-SD card for slightly more: https://www.adafruit.com/products/2088.

The adafruit page claims its current draw is ~25mA, while with the 3rd party display I got, I'm seeing about 100mA of draw.

There is a new init flag for this display (INITR_144GREENTAB), and the places that set the height/width check that flag and set the appropriate width to 128 (or height for rotation) instead of 160.

However, if I use the standard INITR_GREENTAB flag, the demo program does work with the adafruit driver, but not with the Teensy driver.
 
Hello, I'm new to this forum and I sure could use a little help.

I,m building the adafruit "uncannyEyes" project for halloween.
I have a new Teensy3.2 and a pair of 1.8 TFTs <128*160 ST7735 driver chip>
I,m running arduino IDE version 1.6.12 and the above mentioned beta version of teensyduino .
Should i roll back my verion of arduino IDE or go ahead and try it with the beta version.
It sounds like their may be a few quirks ?

Thanks, CJ

I doubt the beta driver will work for you. It didn't for me with a 128x128 display and it didn't work for el sumpreo either. I went back several releases of TeensyDuino and none of the drivers worked for me.

If you temporarily don't install the Teensy version, and install the Adafruit version, it should work fine until a fix is found. You may have to change the initialization from INITR_144GREENTAB to the appropriate display for your system (perhaps INITR_GREENTAB). Hopefully the extra pixels won't change the display (which is targeted to 128x128 displays).
 
Last edited:
I ordered the Adafruit display.

If there is anything you want me to try, before your board arrives, let me know.

<edit>
I was curious, and if I remove the giant if statement on line 578 of Adafruit_ST7735 that enables the special hardware support, the test program (using INITR_GREENTAB) works fine.
 
Last edited:
Unfortunately, the Adafruit_ST7735 library just does not work for me, using the 128x128 TFT display I've been using for uncannyEyes.

I cloned the graphicstest and changed the pin defaults for my screen:
  • CS is pin 10
  • D/C is pin A1/15
  • Reset is pin 8
  • SCLK is pin 13
  • MOSI is pin 11
  • I used the INITR_GREENTAB initialization option (note in the Adafruit version, INITR_128GREENTAB is the preferred version, but that isn't in the Teensy version).
  • screen powered via 3.3v regulator off of VIN
  • Teensy 3.1

If I substitute the current Adafruit library for the Teensy one it works fine (part of the screen is clipped because the 128x128 screen is smaller than the 160x128 display, but the rest of the stuff is displayed on the screen).

If I use the current 1.31 beta2 Teensy version, the screen just stays blank.

Note, this is a Teensy 3.1, and not the Teensy 3.6, so the recent changes should not matter. Unlike uncannyEyes, this test just uses the standard graphics primitives.

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
 ****************************************************/

// This Teensy3 native optimized version requires specific pins
//
#define sclk 13  // 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   A1  //  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

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#if defined(__SAM3X8E__)
    #undef __FlashStringHelper::F(string_literal)
    #define F(string_literal) string_literal
#endif

// Option 1: use any pins but a little slower
//Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);

// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);
float p = 3.1415926;

 
#define Neutral 0
#define Press 1
#define Up 2
#define Down 3
#define Right 4
#define Left 5
 
// Check the joystick position
int CheckJoystick()
{
  int joystickState = analogRead(3);
  
  if (joystickState < 50) return Left;
  if (joystickState < 150) return Down;
  if (joystickState < 250) return Press;
  if (joystickState < 500) return Right;
  if (joystickState < 650) return Up;
  return Neutral;
}


void setup(void) {
  pinMode(sdcs, INPUT_PULLUP);  // don't touch the SD card
  Serial.begin(9600);
  Serial.print("hello!");

  // 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

  //tft.initR(INITR_144GREENTAB); // initialize a ST7735R chip with 128x128 display, green tab
  tft.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab

  Serial.println("init");

  uint16_t time = millis();
  tft.fillScreen(ST7735_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);

  // large block of text
  tft.fillScreen(ST7735_BLACK);
  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);
  delay(1000);

  // tft print function!
  tftPrintTest();
  delay(4000);

  // a single pixel
  tft.drawPixel(tft.width()/2, tft.height()/2, ST7735_GREEN);
  delay(500);

  // line draw test
  testlines(ST7735_YELLOW);
  delay(500);

  // optimized lines
  testfastlines(ST7735_RED, ST7735_BLUE);
  delay(500);

  testdrawrects(ST7735_GREEN);
  delay(500);

  testfillrects(ST7735_YELLOW, ST7735_MAGENTA);
  delay(500);

  tft.fillScreen(ST7735_BLACK);
  testfillcircles(10, ST7735_BLUE);
  testdrawcircles(10, ST7735_WHITE);
  delay(500);

  testroundrects();
  delay(500);

  testtriangles();
  delay(500);

  mediabuttons();
  delay(500);

  Serial.println("done");
  delay(1000);
}

void loop() {
  tft.invertDisplay(true);
  delay(500);
  tft.invertDisplay(false);
  delay(500);
  int joy = CheckJoystick();
  switch (joy)
  {
    case Left:
      Serial.println("Left");
      break;
    case Right:
      Serial.println("Right");
      break;
    case Up:
      Serial.println("Up");
      break;
    case Down:
      Serial.println("Down");
      break;
    case Press:
      Serial.println("Press");
      break;
  }
}

void testlines(uint16_t color) {
  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(0, 0, x, tft.height()-1, color);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(0, 0, tft.width()-1, y, color);
  }

  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(tft.width()-1, 0, 0, y, color);
  }

  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(0, tft.height()-1, x, 0, color);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(0, tft.height()-1, tft.width()-1, y, color);
  }

  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color);
  }
  for (int16_t y=0; y < tft.height(); y+=6) {
    tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color);
  }
}

void testdrawtext(char *text, uint16_t color) {
  tft.setCursor(0, 0);
  tft.setTextColor(color);
  tft.setTextWrap(true);
  tft.print(text);
}

void testfastlines(uint16_t color1, uint16_t color2) {
  tft.fillScreen(ST7735_BLACK);
  for (int16_t y=0; y < tft.height(); y+=5) {
    tft.drawFastHLine(0, y, tft.width(), color1);
  }
  for (int16_t x=0; x < tft.width(); x+=5) {
    tft.drawFastVLine(x, 0, tft.height(), color2);
  }
}

void testdrawrects(uint16_t color) {
  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color);
  }
}

void testfillrects(uint16_t color1, uint16_t color2) {
  tft.fillScreen(ST7735_BLACK);
  for (int16_t x=tft.width()-1; x > 6; x-=6) {
    tft.fillRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color1);
    tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color2);
  }
}

void testfillcircles(uint8_t radius, uint16_t color) {
  for (int16_t x=radius; x < tft.width(); x+=radius*2) {
    for (int16_t y=radius; y < tft.height(); y+=radius*2) {
      tft.fillCircle(x, y, radius, color);
    }
  }
}

void testdrawcircles(uint8_t radius, uint16_t color) {
  for (int16_t x=0; x < tft.width()+radius; x+=radius*2) {
    for (int16_t y=0; y < tft.height()+radius; y+=radius*2) {
      tft.drawCircle(x, y, radius, color);
    }
  }
}

void testtriangles() {
  tft.fillScreen(ST7735_BLACK);
  int color = 0xF800;
  int t;
  int w = 63;
  int x = 159;
  int y = 0;
  int z = 127;
  for(t = 0 ; t <= 15; t+=1) {
    tft.drawTriangle(w, y, y, x, z, x, color);
    x-=4;
    y+=4;
    z-=4;
    color+=100;
  }
}

void testroundrects() {
  tft.fillScreen(ST7735_BLACK);
  int color = 100;
  int i;
  int t;
  for(t = 0 ; t <= 4; t+=1) {
    int x = 0;
    int y = 0;
    int w = 127;
    int h = 159;
    for(i = 0 ; i <= 24; i+=1) {
      tft.drawRoundRect(x, y, w, h, 5, color);
      x+=2;
      y+=3;
      w-=4;
      h-=6;
      color+=1100;
    }
    color+=100;
  }
}

void tftPrintTest() {
  tft.setTextWrap(false);
  tft.fillScreen(ST7735_BLACK);
  tft.setCursor(0, 30);
  tft.setTextColor(ST7735_RED);
  tft.setTextSize(1);
  tft.println("Hello World!");
  tft.setTextColor(ST7735_YELLOW);
  tft.setTextSize(2);
  tft.println("Hello World!");
  tft.setTextColor(ST7735_GREEN);
  tft.setTextSize(3);
  tft.println("Hello World!");
  tft.setTextColor(ST7735_BLUE);
  tft.setTextSize(4);
  tft.print(1234.567);
  delay(1500);
  tft.setCursor(0, 0);
  tft.fillScreen(ST7735_BLACK);
  tft.setTextColor(ST7735_WHITE);
  tft.setTextSize(0);
  tft.println("Hello World!");
  tft.setTextSize(1);
  tft.setTextColor(ST7735_GREEN);
  tft.print(p, 6);
  tft.println(" Want pi?");
  tft.println(" ");
  tft.print(8675309, HEX); // print 8,675,309 out in HEX!
  tft.println(" Print HEX!");
  tft.println(" ");
  tft.setTextColor(ST7735_WHITE);
  tft.println("Sketch has been");
  tft.println("running for: ");
  tft.setTextColor(ST7735_MAGENTA);
  tft.print(millis() / 1000);
  tft.setTextColor(ST7735_WHITE);
  tft.print(" seconds.");
}

void mediabuttons() {
  // play
  tft.fillScreen(ST7735_BLACK);
  tft.fillRoundRect(25, 10, 78, 60, 8, ST7735_WHITE);
  tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_RED);
  delay(500);
  // pause
  tft.fillRoundRect(25, 90, 78, 60, 8, ST7735_WHITE);
  tft.fillRoundRect(39, 98, 20, 45, 5, ST7735_GREEN);
  tft.fillRoundRect(69, 98, 20, 45, 5, ST7735_GREEN);
  delay(500);
  // play color
  tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_BLUE);
  delay(50);
  // pause color
  tft.fillRoundRect(39, 98, 20, 45, 5, ST7735_RED);
  tft.fillRoundRect(69, 98, 20, 45, 5, ST7735_RED);
  // play color
  tft.fillTriangle(42, 20, 42, 60, 90, 40, ST7735_GREEN);
}

<edit>
I was curious, I went back to previous Teensy versions back to 1.26, and none of them seem to work with the teensy version of Adafruit_ST7735 using the INITR_GREENTAB option.]

So for now, I'm going to keep the Adafruit version in my tree instead of the Teensy version. For me, the work around is acceptable, but presumably there might be other people trying to use this display.



In running the unCannyEyes on Teensy 3.6 I had to set the SPI clock rate to 18MHz or less using the OLED displays, depending on the running speed of the Teensy I would get a corrupt display or no display. Just a thought.

// EYE-RENDERING FUNCTION --------------------------------------------------

SPISettings settings(18000000, MSBFIRST, SPI_MODE3); // Teensy 3.1 max SPI

void drawEye( // Renders one eye. Inputs must be pre-clipped & valid.
 
In running the unCannyEyes on Teensy 3.6 I had to set the SPI clock rate to 18MHz or less using the OLED displays, depending on the running speed of the Teensy I would get a corrupt display or no display. Just a thought.

// EYE-RENDERING FUNCTION --------------------------------------------------

SPISettings settings(18000000, MSBFIRST, SPI_MODE3); // Teensy 3.1 max SPI

void drawEye( // Renders one eye. Inputs must be pre-clipped & valid.

Note, OLED displays use the SSD1351 driver, and yes it is well known the displays can't be refreshed that fast. I can currently get 24 Mhz from a Teensy 3.6 using the Adafruit display, and 72 Mhz using the Newhaven display.

However, the ST7735 bug is for the TFT display. Using the Adafruit driver (which avoids setting the special sauce for faster SPI support), I can run two third party displays up to 240 Mhz (on the Teensy 3.6, but I can't run 2 displays at all on the Teensy 3.1). But the OLED displays look better, particularly if you aren't viewing the display head on.
 
Status
Not open for further replies.
Back
Top