Skip to content

Instantly share code, notes, and snippets.

@Bolukan
Created March 7, 2019 20:32
Show Gist options
  • Save Bolukan/b8ee0c7e0fe9228c46e7718c2cc010ef to your computer and use it in GitHub Desktop.
Save Bolukan/b8ee0c7e0fe9228c46e7718c2cc010ef to your computer and use it in GitHub Desktop.
MyLibrary
#include <MyLibrary.h>
MyLibrary::MyLibrary()
{}
void MyLibrary::begin(void)
{
Serial.print("MyLibrary text1: ");
Serial.println(text1);
Serial.print("MyLibrary text2: ");
Serial.println(text2);
#ifdef text3
Serial.print("MyLibrary text3: ");
Serial.println(text3);
#endif
Serial.println("Library out");
}
#ifndef MyLibrary_h
#define MyLibrary_h
#define text1 "Text 1 Library"
#define text2 "Text 2 Library"
#include <Arduino.h>
class MyLibrary
{
public:
// Class constructor
MyLibrary();
void begin(void);
private:
};
#endif
#ifdef text2
#undef text2
#define text2 "Text 2 Main before include"
#endif
#include <Arduino.h>
#include <MyLibrary.h>
#ifdef text1
#undef text1
#define text1 "Text 1 Main after include"
#endif
#define text3 "Text 3 Main only"
MyLibrary mylib = MyLibrary();
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println();
Serial.print("Main text1: ");
Serial.println(text1);
#ifdef text2
Serial.print("Main text2: ");
Serial.println(text2);
#endif
Serial.print("Main text3: ");
Serial.println(text3);
mylib.begin();
}
void loop() {
// put your main code here, to run repeatedly:
}
Main text1: Text 1 Main after include
Main text2: Text 2 Library
Main text3: Text 3 Main only
MyLibrary text1: Text 1 Library
MyLibrary text2: Text 2 Library
Library out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment