Hello, I just want to confirm with others that it is OK to create a user library with only .h file in it. The purpose is obviously to have custom include file shared by many sketches.
The process of building the project looks somewhat different:
when compiling libraries , compiler only says "Using library blablabla.h ..." but no compiler running for this library. In the end everything is built and linked .
Tried this in Arduino IDE and Visual Studio + vMicro - both work.
Please let me know that I am not missing something to be surprised in he future
Vladimir
This is a shortened file version as it is rather large. The rest is similar definition types.
/**********************************************
In-Flight Controller Definitions
***********************/ #ifndef IFC_H #define IFC_H
/ List of Global Defines ******************/
#defineSD_PRESENT // include SD card support #defineIFC_BATTERY #defineTHRUST #defineAVIONICS
//#defineDEBUG_AVIONICS
/************************* AVIONICS *********************************/ #define AVIO_PIN 47 // SS pin to control avionics module
#define SEA_LEVEL_PRESSURE 1014 // in hPa updated using buttons in IFC Setup screen
// integer is fine as it must be stored in EEPROM #define REF_ALTITUDE 100 // reference altitude in ft, updated in IFC Setup screen,
// integer is fine as it must be stored in EEPROM #define TOP_SPEED 800 // in mph linear ratio calibration... updated in Setup
/********************************************************************/
const byte AVIO_WRITE_SETUP = 11; // write setup variables to Avionics module
const byte AVIO_READ_DATA = 12; // read Avio data from avionics module
const byte AVIO_READ_SETUP = 13; // read Avio setup for debug confirmation
//typedef struct AVIO_SETUP
struct AVIO_SETUP
{
int slp; // sea level pressure in hPa was setup in Setup screen
int refAlt; // reference Altitude in ft was setup in Setup screen
int top_speed; // top speed for calibration in mph from setup screen
byte calibrate; // '1' means read averaged airspeed calibration code and store in EEPROM,
// '0' means no calibration
// int speed_0_code; // code read for speed 0 event triggered from setup button
};
//typedef struct AVIO_GET_DATA
struct AVIO_GET_DATA
{
int absAlt; // in ft from Avionics module
int relAlt; // relative Altitude in ft, could be negative
int vario; // ft per min in US units, could be negative
int airspeed; // true adjusted airspeed reading mph
};
#endif IFC_H
It is a "pure" include file with definitions.
Vlad
eBirdman:
But if I put in-line functions, I could still have only .h file , is it so?
No. If you implement functions, the implementation belongs in a source file.
While you can sometimes get away with implementing functions in a header file, there will be someone, somewhere, that can't use your library because you have done that. So, don't do that.