Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: detecting Teensyduino, version, board and the like at compile time

  1. #1
    Junior Member
    Join Date
    Jul 2021
    Location
    Switzerland
    Posts
    2

    detecting Teensyduino, version, board and the like at compile time

    This is my very first posting to this forum

    I am developing and using a couple of programs originally on arduino hardware. I am still working with the Arduino IDE on Linux but using different hardware like ESP32 boards and others.
    I build a special type of portable musical instruments for harmonical experiments and performances. They use *all* the available processing power, so the Teensy 4.1 got my interest
    I expect the first few T4.1 to arrive these days and would like to prepare my code for experiments.

    So I need a possibility to detect Teensyduino at compile time to adapt the code.
    For later debugging I like my programs to remember (hard and) software versions they were compiled for.
    On ESP32 boards I do things like:
    Code:
    #if defined ESP32
    ... // code for ESP32 goes here
    #endif
    How can I do that on a Teensy?
    How to read the Teensyduino version?
    How do I get the used board (like Teensy 3.6 or Teensy 4.1)?

    On ESP I use esp_get_idf_version(); to know the underlying esp idf software version, and I display the chip revision on booting.
    There is also ESP_ARDUINO_VERSION.
    I do not know if there is similar info on the Teensy or not.

    Thanks for any hints and pointers

  2. #2
    Member
    Join Date
    Aug 2018
    Location
    Brisbane, Australia
    Posts
    77
    Quote Originally Posted by OutOfLine View Post
    How to read the Teensyduino version?
    There is a preprocessor symbol containing the version number (currently 154)
    Code:
    TEENSYDUINO
    Quote Originally Posted by OutOfLine View Post
    How do I get the used board (like Teensy 3.6 or Teensy 4.1)?
    Code:
    #if defined(__MKL26Z64__)
    //		"Teensy LC [MKL26Z64]"
    #elif defined(__MK20DX256__)
    //		"Teensy 3.2 [MK20DX256]"
    #elif defined(__MK64FX512__)
    //		"Teensy 3.5 [MK64FX512]"
    #elif defined(__MK66FX1M0__)
    //		"Teensy 3.6 [MK66FX1M0]"
    #elif defined(ARDUINO_TEENSY40)
    //		"Teensy 4.0 [IMXRT1052]"
    #elif defined(ARDUINO_TEENSY41)
    //		"Teensy 4.1 [IMXRT1052]"
    #else
    //		"*** Teensy ??? ***"
    #endif

  3. #3
    Junior Member
    Join Date
    Jul 2021
    Location
    Switzerland
    Posts
    2
    Thanks a lot, quick and very helpful.

  4. #4
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,575
    Also with later version of Teensyduino you have the ability to like:

    Code:
    #ifdef ARDUINO_TEENSY41
    for Teensy 4.1 dito for most/all of the other Teensy

    I another hint, if you wish to see how things are compiled, you should turn on verbose compiles. It is in the Arduno preferences dialog. It will show you the command lines used to build things

Posting Permissions

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