Conditional Library initialization

I am using the wonderful u8glib. Is there anyway to initialize based on a variable?

Right now I have have to comment and uncomment based on which initialization parameter i would like to use

Because this is not the only library i need to comment/uncomment (i have about 7 “profiles” of intialization settings for various libraries) I would love to do it in a switch case or with a function.

Any help would be appreciated.

#include “U8glib.h”
#include “M2tk.h”
#include “utility/m2ghu8g.h”
#include <stdlib.h> // for itoa
#include <SoftwareSerial.h>

SoftwareSerial bluetooth(BT_RX_PIN,BT_TX_PIN); // RX | TX

//ANGEL LCD-g7
//U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI

//EBLADE
U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI

//ANGEL LED, A1
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0); // I2C / TWI

This has been discussed before. You should search the forum.

Hi

I probably would isolate the constructor in several different c++ (.ino) files. Of course these files will be very small and only contain one constructor. Then create several projects. Each project contains one of the constructor files and some common code. Each of the u8g classes is derived from U8GLIB master class, so you should be able to do an extern U8GLIB u8g; in the common part of the code.

Not tested....

Oliver