LowPowerLab Forum

Hardware support => MoteinoMEGA => Topic started by: pedro.albuquerque on November 18, 2017, 11:53:37 AM

Title: Identify board at compile time
Post by: pedro.albuquerque on November 18, 2017, 11:53:37 AM
I have seen some code that allow to determine the board being used/select at compile time.
code like

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

When using Atom with platformIO the value that is representing Moteino is

#if defined( ARDUINO_AVR_MOTEINO) || defined(ARDUINO_AVR_MOTEINOMEGA) || defined(ARDUINO_AVR_NANO)

and is working fine, but....  when using Arduino IDE, this value are not defined, nor the ones above "__AVR_ATmega1280__"

What would be the right value to test for Moteino and MoteinoMega ?

thank you for any help you can provide.
Title: Re: Identify board at compile time
Post by: pedro.albuquerque on November 18, 2017, 12:06:07 PM
meanwhile managed to find a piece of code with this MACRO define.

Maybe someone else have the doubt  :D

#if defined(__AVR_ATmega1284P__)
    Serial.println("MOTEINOMEGA");
#endif
#if defined(__AVR_ATmega328P__)
    Serial.println("MOTEINO");
  #endif




Title: Re: Identify board at compile time
Post by: Felix on November 18, 2017, 10:07:16 PM
Yes that works and I use it in my own sketches.