Teensyduino 1.58 Beta #3

Yes, the new toolchain is the future.

Arduino IDE 2.0.3 bugs should be discussed on Arduino's forum or github issues. Talking about them here is ok, but does no good.

FWIW, I still personally end up mostly using Arduino 1.8.19, because of the sorry state of 2.0.3 serial monitor.
 
For anyone {USER} using TyCommander - or looking for an IDE 2.0.3 solution to the symptom of poor Serial Monitor connectivity/usage.

Install TyCommander to some {PLACE}

Then in proper teensy {ver #} folder <on Windows>: C:\Users\{USER}\AppData\Local\Arduino15\packages\teensy\hardware\avr\{ver #}

Make this: "C:\Users\{USER}\AppData\Local\Arduino15\packages\teensy\hardware\avr\0.58.3\platform.local.txt"
Code:
tools.teensyloader.cmd.path=[B]{PLACE}[/B]\TyCommanderC.exe
tools.teensyloader.upload.pattern="{cmd.path}" upload --autostart --wait --delegate "{build.path}/{build.project_name}.hex"

The key there is the "--delegate" that @koromix added. The IDE will open TyCommander and ask "what Teensy" {it then associates that sketch and won't ask again}, it takes 'Serial' offline into bootloader which inspires Teensy Loader to upload the indicated .Hex or .eHex file to the chosen Teensy where it comes back online with TyCommander holding the link to SerMon restored.

TyCommander can upload normal '.Hex' but, Only Teensy.exe can upload '.eHex' to Encrypted 1062's and this '--delegate' makes that happen, and in this case effectively allows 'Integrate to Arduino IDE 2' where TyCommander goes offline allowing upload and resume of SerMon.

This gives a SerMon that reliably works for one or more connected Teensy devices. Same sketch will upload to same model Teensy clicking TyCommander GUI Bootloader (or Reset). To build same sketch for different model Teensy in the GUI first 'Right click the associated Teensy' and click 'Drop association' to prevent say 'T_4.1 .hex going toward a T_4.0' and failing.

ide2TyComm.jpg
 
Last edited:
Coremark is 4% higher with new compiler.
I told you about this new information a long time ago :) But anyway, I'm glad that a newer toolchain is finally being used. It would be nice to see this for decades old components like the CMSIS or libraries, too.
 
I told you about this new information a long time ago :) But anyway, I'm glad that a newer toolchain is finally being used. It would be nice to see this for decades old components like the CMSIS or libraries, too.

4% gain was fun to see.
What is odd is the different results IDE 1 .vs. 2 - Seems I did it on two machines, but no comments on anyone else trying it to verify. Different build results may be trivial - or could be a bad surprise.
 
4% gain was fun to see.
What is odd is the different results IDE 1 .vs. 2 - Seems I did it on two machines, but no comments on anyone else trying it to verify. Different build results may be trivial - or could be a bad surprise.

Are the same build flags used?
 
Are the same build flags used?

Collected this - both IDE 1 and 2 give this same SIZE info block - no diff in CodeCompare:
Code:
Memory Usage on Teensy 4.1:
  FLASH: code:16748, data:3992, headers:8952   free for files:8096772
   RAM1: variables:4864, code:14128, padding:18640   free for local variables:486656
   RAM2: variables:12384  free for malloc/new:511904

Gotta restart machine - seems the one build already had a PCH it used. Removed most <COMMON> sections to try to make it readable and shorter:
IDE12Diff.jpg
 
Since it appears there is no beta #4 with String corrections, I tried that beta #3 then copied the cores directory which contains String corrections in the GitHub but with no avail:

Code:
WString.cpp: In constructor String::String(unsigned char)
 
WString.cpp: 70:9: error: 'utoa' was not declared in this scope; did you mean 'ultoa'?
   70 |         utoa(c, buf, 10)
   |         ^~~~
   |         ultoa
WString.cpp: In constructor String::String(int, unsigned char)
 
WString.cpp: 78:9: error: 'itoa' was not declared in this scope; did you mean 'ltoa'?
   78 |         itoa(value, buf, base)
   |         ^~~~
   |         ltoa
WString.cpp: In constructor String::String(unsigned int, unsigned char)
 
WString.cpp: 86:9: error: 'utoa' was not declared in this scope; did you mean 'ultoa'?
   86 |         utoa(value, buf, base)
   |         ^~~~
   |         ultoa
Error compiling core

Also, I'm using Visual Studio C++ with vMicro extension (using Arduino 1.8).

EDIT:

It looks as if "/* #if defined(__STRICT_ANSI__) || (defined(_NEWLIB_VERSION) && (__NEWLIB__ < 2 || __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 2))" comments utoa and itoa.

EDIT2:

I had to replace them as
Code:
char * utoa(unsigned int val, char *buf, int radix) { return ultoa(val, buf, radix); }
char * itoa(int val, char *buf, int radix) { return ltoa(val, buf, radix); }
to be able to proceed further.
 
Last edited:
I tried using 1.58 beta 3 on a Mac running Sierra 10.12.6 and Arduino generated errors:

Arduino: 1.8.19 (Mac OS X), TD: 1.58-beta3, Board: "Teensy 4.0, Serial, 600 MHz, Faster, US English"

dyld: lazy symbol binding failed: Symbol not found: ____chkstk_darwin
Referenced from: /Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++
Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: ____chkstk_darwin
Referenced from: /Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++
Expected in: /usr/lib/libSystem.B.dylib

signal: abort trap
/Applications/Arduino.app/Contents/Java/arduino-builder returned 255
Error compiling for board Teensy 4.0.


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


So I went back to 1.57 and it compiled and Teensy Loader worked.
I just wanted let you know what I saw with 1.58 beta 3
 
I was playing with some SmartMatrix demos (such as Adafruit_Gfx), and the new compiler in the 1.58 beta releases throws some new warnings for the Smartmatrix library. I will post this over at the Smartmaxtrix forum as well:

Code:
In file included from /home/meissner/Arduino/libraries/SmartMatrix/src/Layer_BackgroundGfx.h:173,
                 from /home/meissner/Arduino/libraries/SmartMatrix/src/SmartMatrix.h:59,
                 from /home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:39:
/home/meissner/Arduino/libraries/SmartMatrix/src/Layer_BackgroundGfx_Impl.h: In instantiation of 'void SMLayerBackgroundGFX<RGB, optionFlags>::swapBuffers(bool) [with RGB = rgb24; unsigned int optionFlags = 0]':
/home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:142:55:   required from here
/home/meissner/Arduino/libraries/SmartMatrix/src/Layer_BackgroundGfx_Impl.h:197:19: warning: 'void* memcpy(void*, const void*, size_t)' writing to an object of type 'struct rgb24' with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
  197 |             memcpy(backgroundBuffers[1], backgroundBuffers[0], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/meissner/Arduino/libraries/SmartMatrix/src/SmartMatrix.h:50,
                 from /home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:39:
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixCommon.h:139:16: note: 'struct rgb24' declared here
  139 | typedef struct rgb24 {
      |                ^~~~~
In file included from /home/meissner/Arduino/libraries/SmartMatrix/src/Layer_BackgroundGfx.h:173,
                 from /home/meissner/Arduino/libraries/SmartMatrix/src/SmartMatrix.h:59,
                 from /home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:39:
/home/meissner/Arduino/libraries/SmartMatrix/src/Layer_BackgroundGfx_Impl.h:199:19: warning: 'void* memcpy(void*, const void*, size_t)' writing to an object of type 'struct rgb24' with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
  199 |             memcpy(backgroundBuffers[0], backgroundBuffers[1], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/meissner/Arduino/libraries/SmartMatrix/src/SmartMatrix.h:50,
                 from /home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:39:
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixCommon.h:139:16: note: 'struct rgb24' declared here
  139 | typedef struct rgb24 {
      |                ^~~~~
In file included from /home/meissner/Arduino/libraries/SmartMatrix/src/SmartMatrix.h:218,
                 from /home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:39:
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixTeensy4Hub75Refresh_Impl.h: In instantiation of 'static void SmartMatrixRefreshT4<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::hardwareSetup() [with int refreshDepth = 36; int matrixWidth = 64; int matrixHeight = 64; unsigned char panelType = 2; long unsigned int optionFlags = 0]':
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixTeensy4Hub75Refresh_Impl.h:389:18:   required from 'static void SmartMatrixRefreshT4<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::begin() [with int refreshDepth = 36; int matrixWidth = 64; int matrixHeight = 64; unsigned char panelType = 2; long unsigned int optionFlags = 0]'
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixTeensy4Hub75Calc_Impl.h:272:97:   required from 'void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::begin() [with int refreshDepth = 36; int matrixWidth = 64; int matrixHeight = 64; unsigned char panelType = 2; long unsigned int optionFlags = 0]'
/home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:380:15:   required from here
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixTeensy4Hub75Refresh_Impl.h:669:88: warning: taking address of packed member of 'SmartMatrixRefreshT4<36, 64, 64, 2, 0>::timerpair' may result in an unaligned pointer value [-Waddress-of-packed-member]
  669 |     sourceAddress = (volatile uint32_t*) & (matrixUpdateRows[0].rowbits[0].timerValues.timer_oe);
      |                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /home/meissner/Arduino/libraries/SmartMatrix/src/SmartMatrix.h:219,
                 from /home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:39:
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixTeensy4Hub75Calc_Impl.h: In instantiation of 'static void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::loadMatrixBuffers48(volatile rowDataStruct*, unsigned int) [with int refreshDepth = 36; int matrixWidth = 64; int matrixHeight = 64; unsigned char panelType = 2; long unsigned int optionFlags = 0; SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::rowDataStruct = SmartMatrixRefreshT4<36, 64, 64, 2, 0>::rowDataStruct]':
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixTeensy4Hub75Calc_Impl.h:548:24:   required from 'static void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::loadMatrixBuffers(unsigned int) [with int refreshDepth = 36; int matrixWidth = 64; int matrixHeight = 64; unsigned char panelType = 2; long unsigned int optionFlags = 0]'
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixTeensy4Hub75Calc_Impl.h:168:113:   required from 'static void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::matrixCalculations(bool) [with int refreshDepth = 36; int matrixWidth = 64; int matrixHeight = 64; unsigned char panelType = 2; long unsigned int optionFlags = 0]'
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixTeensy4Hub75Calc_Impl.h:270:121:   required from 'void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::begin() [with int refreshDepth = 36; int matrixWidth = 64; int matrixHeight = 64; unsigned char panelType = 2; long unsigned int optionFlags = 0]'
/home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:380:15:   required from here
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixTeensy4Hub75Calc_Impl.h:384:15: warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'rgb48' {aka 'struct rgb48'}; use assignment or value-initialization instead [-Wclass-memaccess]
  384 |         memset(tempRow0, 0, sizeof(tempRow0));
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/meissner/Arduino/libraries/SmartMatrix/src/SmartMatrix.h:50,
                 from /home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:39:
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixCommon.h:159:16: note: 'rgb48' {aka 'struct rgb48'} declared here
  159 | typedef struct rgb48 {
      |                ^~~~~
In file included from /home/meissner/Arduino/libraries/SmartMatrix/src/SmartMatrix.h:219,
                 from /home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:39:
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixTeensy4Hub75Calc_Impl.h:385:15: warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'rgb48' {aka 'struct rgb48'}; use assignment or value-initialization instead [-Wclass-memaccess]
  385 |         memset(tempRow1, 0, sizeof(tempRow1));
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/meissner/Arduino/libraries/SmartMatrix/src/SmartMatrix.h:50,
                 from /home/meissner/Arduino/Tests/RGB_Matrix/Adafruit_Gfx/Adafruit_Gfx.ino:39:
/home/meissner/Arduino/libraries/SmartMatrix/src/MatrixCommon.h:159:16: note: 'rgb48' {aka 'struct rgb48'} declared here
  159 | typedef struct rgb48 {
      |                ^~~~~
Memory Usage on Teensy 4.1:
  FLASH: code:53692, data:9864, headers:9144   free for files:8053764
   RAM1: variables:37856, code:51048, padding:14488   free for local variables:420896
   RAM2: variables:19680  free for malloc/new:504608

Here is the code I was using:

Code:
/*
 * This example shows how to use the Adafruit_GFX compatible Layers in SmartMatrix Library
 * This example was adapted from Adafruit's FX example for the Adafruit ILI9341 Breakout and Shield, see text below
 */

/***************************************************
  This is our GFX example for the Adafruit ILI9341 Breakout and Shield
  ----> http://www.adafruit.com/products/1651
  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
 ****************************************************/

#define USE_ADAFRUIT_GFX_LAYERS

// uncomment one line to select your MatrixHardware configuration - configuration header needs to be included before <SmartMatrix.h>
//#include <MatrixHardware_Teensy3_ShieldV4.h>        // SmartLED Shield for Teensy 3 (V4)
//#include <MatrixHardware_Teensy4_ShieldV5.h>        // SmartLED Shield for Teensy 4 (V5)
//#include <MatrixHardware_Teensy3_ShieldV1toV3.h>    // SmartMatrix Shield for Teensy 3 V1-V3
//#include <MatrixHardware_Teensy4_ShieldV4Adapter.h> // Teensy 4 Adapter attached to SmartLED Shield for Teensy 3 (V4)
//#include <MatrixHardware_ESP32_V0.h>                // This file contains multiple ESP32 hardware configurations, edit the file to define GPIOPINOUT (or add #define GPIOPINOUT with a hardcoded number before this #include)
//#include "MatrixHardware_Custom.h"                  // Copy an existing MatrixHardware file to your Sketch directory, rename, customize, and you can include it like this

#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
#include <MatrixHardware_Teensy4_ShieldV5.h>		// SmartLED Shield for Teensy 4 (V5)

#elif defined(ARDUINO_TEENSY35) || defined(ARDUINO_TEENSY36)
#include <MatrixHardware_Teensy4_ShieldV4.h>		// SmartLED Shield for Teensy 4 (V5)

#else
#error "Include the correct header for the microprocessor"
#endif

#include <SmartMatrix.h>

#define COLOR_DEPTH 24                  // Choose the color depth used for storing pixels in the layers: 24 or 48 (24 is good for most sketches - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24)
#define kMatrixWidth 64                 // Set to the width of your display, must be a multiple of 8
#define kMatrixHeight 64                // Set to the height of your display
const uint8_t kRefreshDepth = 36;       // Tradeoff of color quality vs refresh rate, max brightness, and RAM usage.  36 is typically good, drop down to 24 if you need to.  On Teensy, multiples of 3, up to 48: 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48.  On ESP32: 24, 36, 48
const uint8_t kDmaBufferRows = 4;       // known working: 2-4, use 2 to save RAM, more to keep from dropping frames and automatically lowering refresh rate.  (This isn't used on ESP32, leave as default)

// Choose the configuration that matches your panels.  See more details in
// MatrixCommonHub75.h and the docs: https://github.com/pixelmatix/SmartMatrix/wiki
#if kMatrixHeight == 64
const uint8_t kPanelType = SM_PANELTYPE_HUB75_64ROW_MOD32SCAN;

#elif kMatrixHeight == 32
const uint8_t kPanelType = SM_PANELTYPE_HUB75_32ROW_MOD16SCAN;

#elif kMatrixHeight == 16
const uint8_t kPanelType = SM_PANELTYPE_HUB75_16ROW_MOD8SCAN;

#else
#error "Update setting kPanelType"
#endif

const uint32_t kMatrixOptions = (SM_HUB75_OPTIONS_NONE);        // see docs for options: https://github.com/pixelmatix/SmartMatrix/wiki

SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);

// There are two Adafruit_GFX compatible layers, a Mono layer and an RGB layer, and this example sketch works with either (choose one):
#if 1
  const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);
  SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
#else
  const uint8_t kMonoLayerOptions = (SM_GFX_MONO_OPTIONS_NONE);
  SMARTMATRIX_ALLOCATE_GFX_MONO_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kMonoLayerOptions);
  
  // these backwards compatible ALLOCATE macros also work:
  //SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kMonoLayerOptions);
  //SMARTMATRIX_ALLOCATE_INDEXED_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kMonoLayerOptions);
#endif

// Assign human-readable names to some common 16-bit color values:
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

// enable this to see the intermediate drawing steps, otherwise screen will only be updated at the end of each test (this slows the tests down considerably)
const bool swapAfterEveryDraw = false;

unsigned long testFillScreen() {
  unsigned long start = micros();
  backgroundLayer.fillScreen(BLACK);
  backgroundLayer.fillScreen(RED);
  backgroundLayer.fillScreen(GREEN);
  backgroundLayer.fillScreen(BLUE);
  backgroundLayer.fillScreen(BLACK);
  return micros() - start;
}

unsigned long testText() {
  backgroundLayer.fillScreen(BLACK);
  unsigned long start = micros();
  backgroundLayer.setCursor(0, 0);
  backgroundLayer.setTextColor(WHITE);  backgroundLayer.setTextSize(1);
  backgroundLayer.println("Hello World!");
  backgroundLayer.setTextColor(YELLOW); backgroundLayer.setTextSize(2);
  backgroundLayer.println(1234.56);
  backgroundLayer.setTextColor(RED);    backgroundLayer.setTextSize(3);
//  backgroundLayer.println(0xDEADBEEF, HEX);
//  backgroundLayer.println();
  backgroundLayer.setTextColor(GREEN);
  backgroundLayer.setTextSize(5);
  backgroundLayer.println("Groop");
  backgroundLayer.setTextSize(2);
  backgroundLayer.println("I implore thee,");
  backgroundLayer.setTextSize(1);
  backgroundLayer.println("my foonting turlingdromes.");
  backgroundLayer.println("And hooptiously drangle me");
  backgroundLayer.println("with crinkly bindlewurdles,");
  backgroundLayer.println("Or I will rend thee");
  backgroundLayer.println("in the gobberwarts");
  backgroundLayer.println("with my blurglecruncheon,");
  backgroundLayer.println("see if I don't!");
  return micros() - start;
}

unsigned long testLines(uint16_t color) {
  unsigned long start, t;
  int           x1, y1, x2, y2,
                w = backgroundLayer.width(),
                h = backgroundLayer.height();

  backgroundLayer.fillScreen(BLACK);

  x1 = y1 = 0;
  y2    = h - 1;
  start = micros();
  for(x2=0; x2<w; x2+=6) {
    backgroundLayer.drawLine(x1, y1, x2, y2, color);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }
  x2    = w - 1;
  for(y2=0; y2<h; y2+=6) {
    backgroundLayer.drawLine(x1, y1, x2, y2, color);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }
  t     = micros() - start; // fillScreen doesn't count against timing
  backgroundLayer.swapBuffers();

  backgroundLayer.fillScreen(BLACK);

  x1    = w - 1;
  y1    = 0;
  y2    = h - 1;
  start = micros();
  for(x2=0; x2<w; x2+=6) {
    backgroundLayer.drawLine(x1, y1, x2, y2, color);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }
  x2    = 0;
  for(y2=0; y2<h; y2+=6) {
    backgroundLayer.drawLine(x1, y1, x2, y2, color);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }
  t    += micros() - start;
  backgroundLayer.swapBuffers();

  backgroundLayer.fillScreen(BLACK);

  x1    = 0;
  y1    = h - 1;
  y2    = 0;
  start = micros();
  for(x2=0; x2<w; x2+=6) {
    backgroundLayer.drawLine(x1, y1, x2, y2, color);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }
  x2    = w - 1;
  for(y2=0; y2<h; y2+=6) {
    backgroundLayer.drawLine(x1, y1, x2, y2, color);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }
  t    += micros() - start;
  backgroundLayer.swapBuffers();

  backgroundLayer.fillScreen(BLACK);

  x1    = w - 1;
  y1    = h - 1;
  y2    = 0;
  start = micros();
  for(x2=0; x2<w; x2+=6) {
    backgroundLayer.drawLine(x1, y1, x2, y2, color);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }
  x2    = 0;
  for(y2=0; y2<h; y2+=6) {
    backgroundLayer.drawLine(x1, y1, x2, y2, color);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }
  t    += micros() - start;
  backgroundLayer.swapBuffers();

  return t;
}
unsigned long testFastLines(uint16_t color1, uint16_t color2) {
  unsigned long start;
  int           x, y, w = backgroundLayer.width(), h = backgroundLayer.height();

  backgroundLayer.fillScreen(BLACK);
  start = micros();
  for(y=0; y<h; y+=5) {
    backgroundLayer.drawFastHLine(0, y, w, color1);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }
  for(x=0; x<w; x+=5) {
    backgroundLayer.drawFastVLine(x, 0, h, color2);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }

  return micros() - start;
}

unsigned long testRects(uint16_t color) {
  unsigned long start;
  int           n, i, i2,
                cx = backgroundLayer.width()  / 2,
                cy = backgroundLayer.height() / 2;

  backgroundLayer.fillScreen(BLACK);
  n     = min(backgroundLayer.width(), backgroundLayer.height());
  start = micros();
  for(i=2; i<n; i+=6) {
    i2 = i / 2;
    backgroundLayer.drawRect(cx-i2, cy-i2, i, i, color);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }

  return micros() - start;
}

unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
  unsigned long start, t = 0;
  int           n, i, i2,
                cx = backgroundLayer.width()  / 2 - 1,
                cy = backgroundLayer.height() / 2 - 1;

  backgroundLayer.fillScreen(BLACK);
  n = min(backgroundLayer.width(), backgroundLayer.height());
  for(i=n; i>0; i-=6) {
    i2    = i / 2;
    start = micros();
    backgroundLayer.fillRect(cx-i2, cy-i2, i, i, color1);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
    t    += micros() - start;
    // Outlines are not included in timing results
    backgroundLayer.drawRect(cx-i2, cy-i2, i, i, color2);
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }

  return t;
}

unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
  unsigned long start;
  int x, y, w = backgroundLayer.width(), h = backgroundLayer.height(), r2 = radius * 2;

  backgroundLayer.fillScreen(BLACK);
  start = micros();
  for(x=radius; x<w; x+=r2) {
    for(y=radius; y<h; y+=r2) {
      backgroundLayer.fillCircle(x, y, radius, color);
      if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
    }
  }

  return micros() - start;
}

unsigned long testCircles(uint8_t radius, uint16_t color) {
  unsigned long start;
  int           x, y, r2 = radius * 2,
                w = backgroundLayer.width()  + radius,
                h = backgroundLayer.height() + radius;

  // Screen is not cleared for this one -- this is
  // intentional and does not affect the reported time.
  start = micros();
  for(x=0; x<w; x+=r2) {
    for(y=0; y<h; y+=r2) {
      backgroundLayer.drawCircle(x, y, radius, color);
      if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
    }
  }

  return micros() - start;
}

unsigned long testTriangles() {
  unsigned long start;
  int           n, i, cx = backgroundLayer.width()  / 2 - 1,
                      cy = backgroundLayer.height() / 2 - 1;

  backgroundLayer.fillScreen(BLACK);
  n     = min(cx, cy);
  start = micros();
  for(i=0; i<n; i+=5) {
    backgroundLayer.drawTriangle(
      cx    , cy - i, // peak
      cx - i, cy + i, // bottom left
      cx + i, cy + i, // bottom right
      backgroundLayer.color565(0, 0, i));
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }

  return micros() - start;
}

unsigned long testFilledTriangles() {
  unsigned long start, t = 0;
  int           i, cx = backgroundLayer.width()  / 2 - 1,
                   cy = backgroundLayer.height() / 2 - 1;

  backgroundLayer.fillScreen(BLACK);
  start = micros();
  for(i=min(cx,cy); i>10; i-=5) {
    start = micros();
    backgroundLayer.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      backgroundLayer.color565(0, i, i));
    t += micros() - start;
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
    backgroundLayer.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
      backgroundLayer.color565(i, i, 0));
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }

  return t;
}

unsigned long testRoundRects() {
  unsigned long start;
  int           w, i, i2,
                cx = backgroundLayer.width()  / 2 - 1,
                cy = backgroundLayer.height() / 2 - 1;

  backgroundLayer.fillScreen(BLACK);
  w     = min(backgroundLayer.width(), backgroundLayer.height());
  start = micros();
  for(i=0; i<w; i+=6) {
    i2 = i / 2;
    backgroundLayer.drawRoundRect(cx-i2, cy-i2, i, i, i/8, backgroundLayer.color565(i, 0, 0));
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }

  return micros() - start;
}

unsigned long testFilledRoundRects() {
  unsigned long start;
  int           i, i2,
                cx = backgroundLayer.width()  / 2 - 1,
                cy = backgroundLayer.height() / 2 - 1;

  backgroundLayer.fillScreen(BLACK);
  start = micros();
  for(i=min(backgroundLayer.width(), backgroundLayer.height()); i>20; i-=6) {
    i2 = i / 2;
    backgroundLayer.fillRoundRect(cx-i2, cy-i2, i, i, i/8, backgroundLayer.color565(0, i, 0));
    if(swapAfterEveryDraw) backgroundLayer.swapBuffers();
  }

  return micros() - start;
}

void setup() {
  Serial.begin(115200);
  matrix.addLayer(&backgroundLayer); 
  matrix.begin();

  // wait for Serial to be ready
  delay(1000);

  matrix.setBrightness(128);

  Serial.println(F("Benchmark                Time (microseconds)"));

  Serial.print(F("Screen fill              "));
  Serial.println(testFillScreen());
  backgroundLayer.swapBuffers();
  delay(500);

  Serial.print(F("Text                     "));
  Serial.println(testText());
  backgroundLayer.swapBuffers();
  delay(3000);

  Serial.print(F("Lines                    "));
  Serial.println(testLines(CYAN));
  backgroundLayer.swapBuffers();
  delay(500);

  Serial.print(F("Horiz/Vert Lines         "));
  Serial.println(testFastLines(RED, BLUE));
  backgroundLayer.swapBuffers();
  delay(500);

  Serial.print(F("Rectangles (outline)     "));
  Serial.println(testRects(GREEN));
  backgroundLayer.swapBuffers();
  delay(500);

  Serial.print(F("Rectangles (filled)      "));
  Serial.println(testFilledRects(YELLOW, MAGENTA));
  backgroundLayer.swapBuffers();
  delay(500);

  Serial.print(F("Circles (filled)         "));
  Serial.println(testFilledCircles(10, MAGENTA));
  backgroundLayer.swapBuffers();
  delay(500);

  Serial.print(F("Circles (outline)        "));
  Serial.println(testCircles(10, WHITE));
  backgroundLayer.swapBuffers();
  delay(500);

  Serial.print(F("Triangles (outline)      "));
  Serial.println(testTriangles());
  backgroundLayer.swapBuffers();
  delay(500);

  Serial.print(F("Triangles (filled)       "));
  Serial.println(testFilledTriangles());
  backgroundLayer.swapBuffers();
  delay(500);

  Serial.print(F("Rounded rects (outline)  "));
  Serial.println(testRoundRects());
  backgroundLayer.swapBuffers();
  delay(500);

  Serial.print(F("Rounded rects (filled)   "));
  Serial.println(testFilledRoundRects());
  backgroundLayer.swapBuffers();
  delay(500);

  Serial.println(F("Done!"));
}

void loop() {
  for(uint8_t rotation=0; rotation<4; rotation++) {
    backgroundLayer.setRotation(rotation);
    testText();
    backgroundLayer.swapBuffers();
    delay(1000);
  }
}
 
I am testing now with the Arduino IDE 2.0.5 and just lost half of day troubleshooting something that I thought was due the code change I made https://forum.pjrc.com/threads/7243...nd-HID-connect-disconnect?p=322784#post322784

One should never do two changes at the same time.

Arduino IDE 2.0.5 has some problems with the USBHost_t36.h or maybe there is new USBHost_t36.h anyway it causes now some glitches that where not with the older Arduino. It might be just that there is some printout activated as I now see constant

Code:
>>>USBHIDParser::out_data
>>>USBHIDParser::out_data
>>>USBHIDParser::out_data
>>>USBHIDParser::out_data

I thought then to find the USBHost_t36.h under the Arduino IDE 2.0.5 directory where it normally has been on Mac, but everything is changed, where is the USBHost_t36.h now?
 
@Garug
Just checked, newest is Arduino IDE 2.0.4 not 2.0.5? Regardless IDE 2.0 serial com is not ready for prime time. It can't catch the 1st output lines and doesn't update the window to the latest lines without some kind of manual intervention. I wouldn't recommend it for debugging yet. I still use it most of the time, but if you're having issues with output don't.

As you noted things are stored differently. If you look at the compiler output you will see:
/Users/yourname/Library/Arduino15/packages/.....
 
Note: As for the not seeing the last lines... There was a fix since the last released version.
You can download from the main arduino.cc software page.

As mentioned there are still many issues with the Serial Monitor, but for serious debugging needing Serial output, I use TyCommander anyway.
 
I think tough the problem, I am having is more related to USBHost_t36.h

if I update my code to the board with Arduino 1.8.19 it works fine. if I update it with the 2.0.5 I get glitches on the Stream Deck display (it updates 90x90 pixel are 60 Hz using HID) and also get the terminal
Code:
>>>USBHIDParser::out_data
output (do not know where that is coming from, not from my code.)

After the code is updated to board, it does not mater if using 1.8.19 or 2.0.5 terminal, it works the same.
 
I think tough the problem, I am having is more related to USBHost_t36.h

if I update my code to the board with Arduino 1.8.19 it works fine. if I update it with the 2.0.5 I get glitches on the Stream Deck display (it updates 90x90 pixel are 60 Hz using HID) and also get the terminal
Code:
>>>USBHIDParser::out_data
output (do not know where that is coming from, not from my code.)

After the code is updated to board, it does not mater if using 1.8.19 or 2.0.5 terminal, it works the same.
Maybe one of us (me?) may have left a debug line uncommented.

Look in the USBHost_t36 directory.
And look in hid.cpp for:
Code:
void USBHIDParser::out_data(const Transfer_t *transfer)
{
	//Serial.printf(">>>USBHIDParser::out_data\n");
	println("USBHIDParser:out_data called (instance)");
Notice the commented out Serial.printf line.
Looks like it is not commented out in where your copy is.

Not sure of your Stream deck display... If it works with 1.8.19 but not 2.0.5, I am wondering if they are both running the same version of Teensyduino?
For example is one running with the rleased TD and other with beta?
 
The big frustration is, I have no idea where this is or how to find that 'Look in the USBHost_t36 directory'

This is Mac Arduino IDE 2.0.5

as for "version of Teensyduino" how do I see that. I just installed the 2.0.5 and it took care f everything.

(I do know where to find the USBHost_t36 directory on 1.8.19 but no idea where it is on 2.0.5)
 
On MacOS, the default location when using Arduino 2.0.x is /Users/{username}/Library/Arduino15/packages/teensy/hardware/avr/{version}/libraries/USBHost_t36

The "Library" folder in your home directory is usually hidden when viewed from Finder. One way to gain familiar Finder access is open Terminal and type "open Library/Arduino15/". Or if you're familiar with MacOS command line usage, just use Terminal.
 
Again I am not a MAC person, but have pulled mine out of the cupboard, and going to update it now... was 2.0.3...

Easy parts: What version of Teensyduino are you running?

With Arduino 2.x:
Screenshot.jpg
You can see it a few different ways:
a) Board manager pane shows: I have 0.58.3 installed. Paul numbered with 0 as keep those who have the released version installed from getting do you want to update prompts...
But this is 58.3 beta release.
b) Compiles, especially if any verbose output is selected.

Teensyduino - probably start up the app, click on the about command and it will tell you.

Where does it install?
On mine I think it is somewhere like:
/users/kurte/Library/Arduino15/packages/teensy/hardware/avr/0.58.3/libraries/USBHost_t36

It obviously would be different on your machine, i.e. different user name, maybe different version....
 
Guarug:
Another Mac user here, to find any folder of file for that matter you can simply use the Go menu in the Finder:
Go/Go to Folder
and then type in the path name into the window that opens, it does not matter if the folder is hidden or not this method will take you to your requested folder.

If you like to make it easier in the future to find you can drag any folder into the sidebar of and open window and you will have something like this:

Screen Shot 2023-03-27 at 4.15.15 PM.jpg

Regards,
Ed
 
Thanks, with the help of /Users/{username}/Library/Arduino15/packages/teensy/hardware/avr/ and Go I found the relevant files

It seems the Arduino IDE 2.0.5 is by default with 1.57.2

also after
Code:
 void USBHIDParser::out_data(const Transfer_t *transfer)
{
	//Serial.printf(">>>USBHIDParser::out_data\n");
	println("USBHIDParser:out_data called (instance)");

the printout is now gone, and less glitches on the screen, but now when zooming in with phone to it I see there is still some, but this is on both environment and also few pixels that should not be, so need to see my code. (this is just test of few graphical primitives)


I have not all these devices connected and fully working using the USBHost_t36.h, so MIDI in/out, Serial, HID, USB_PTP. most of them work at the same time but especially the 3Dmouse and Logitech have some problems when connecting, often causing the system to restart on connection. I think mostly because they are with wireless dongles that seem to make many connections and maybe have some unknown features for USBHost_t36.h

Screenshot 2023-03-28 at 12.07.14.jpg

My purpose is not to raise those issues up here, but ask has there been resent work on USBHost_t36.h and what would be the best version to use.
 
Last edited:
@Garug - not sure here... Especially if for example your Arduino 1.x version and 2.x version are both running the same version of Teensyduino code. Then I would think
they should give you more or less the same results. Assuming you are using the same compiler options.

But if one is running the beta release and the other is running the released version, then there are a few things to check, like:
a) The libraries are different, and maybe something was busted (or fixed) between the two. There have been some hopefully fixes in some of the releases that may or may not apply either good or bad, like:
1) Like issues with some wireless Keyboard or Mouse with Dongles which actually try to create the other object as well (So the Mouse actually will also claim a keyboard object and give a bunch of screwy messages. Tried putting in fixes for this, but sketches may have to add additional Hid parser and mouse and keyboard objects and figure out which one is correct.
2) Keyboard objects now derived from HID Input objects, and sometimes process the data directly (boot format) or rely on HID Parser to handle HID input. This fixed a few different N key rollover keyboards, and also allowed us to need to try to force some keyboards into boot mode... Which failed on some

b) The Beta releases here for Teensyduino, is now using a newer version of the GCC compiler toolset, so things could be different due to this.

If you are not using the beta build, you might be better off using a different forum thread...
 
Yes, as mentioned Arduino IDE 2.0.5 is by default with 1.57.2, and I have been testing that today.

But I could/would very well use beta if that provides help with the wireless mouse etc. and not too badly breaks other stuff.

With IDE 2.0.5 how do I install beta, and can I easily select beta or 1.57.2. if this works would be happy to test the beta and report my findings. (here or elsewhere as appropriate)
 
Back
Top