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

Status
Not open for further replies.

OutOfLine

New member
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
 
How to read the Teensyduino version?
There is a preprocessor symbol containing the version number (currently 154)
Code:
TEENSYDUINO

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
 
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
 
Status
Not open for further replies.
Back
Top