How do I deal with conflicting Libraries? Mainly Colour ENUMS

128x128 pixel 1.5" full colour OLED display with MicroSD card slot. [Product page]
Post Reply
ChiggenWingz
Posts: 3
Joined: Thu Apr 09, 2015 7:21 am

How do I deal with conflicting Libraries? Mainly Colour ENUMS

Post by ChiggenWingz » Sat Apr 11, 2015 6:13 am

So I have my little OLED working fine, and I have it hooked up to my USBDroid board. The goal being to have the screen output data based on how I used a connected Xbox controller. To use the Xbox controller I'm using the USB HOST 2.0 library, but within that library there are other enums of colour names, which seem to conflict. WHITE, BLACK, RED...etc

So heres the first part of the code which is from the "XBOXUSB" example, and as you can see I've grabbed the code out of the oled "fonts_demo" example and put some of it in just to see if I can get the text of "Pants" to display on the screen.

Code: Select all

#include <FTOLED.h>
#include <fonts/SystemFont5x7.h>

#include <XBOXUSB.h>
#include <SPI.h>

// Satisfy the IDE, which needs to see the include statment in the ino too.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SD.h>

#endif

USB Usb;
XBOXUSB Xbox(&Usb);

const byte pin_cs = 7;
const byte pin_dc = 2;
const byte pin_reset = 3;

OLED oled(pin_cs, pin_dc, pin_reset);

void setup() {
  Serial.begin(115200);
#if !defined(__MIPSEL__)
  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
  if (Usb.Init() == -1) {
    Serial.print(F("\r\nOSC did not start"));
    while (1); //halt
  }
  Serial.print(F("\r\nXBOX USB Library Started"));
  
  oled.begin();
  oled.selectFont(SystemFont5x7);
  oled.drawString(0,64,"Pants",WHITE,BLACK);
}
But when compiling I get the following errors. I tried googling library conflicts and didn't find any answers that seemed to deal with the problem other than the modify the library files manually, which I was hoping to avoid.

Code: Select all


In file included from C:\Arduino\libraries\USB_Host_Shield_2.0/xboxEnums.h:21:0,
                 from C:\Arduino\libraries\USB_Host_Shield_2.0/XBOXUSB.h:23,
                 from XBOXUSB.ino:10:
C:\Arduino\libraries\USB_Host_Shield_2.0/controllerEnums.h:137:17: error: 'BLACK' redeclared as different kind of symbol
         BLACK = 8, // Available on the original Xbox controller
                 ^
In file included from C:\Arduino\libraries\FreetronicsOLED/FTOLED.h:58:0,
                 from XBOXUSB.ino:7:
C:\Arduino\libraries\FreetronicsOLED/FTOLED_Colours.h:13:14: error: previous declaration of 'const Colour BLACK'
 const Colour BLACK                = {   0/8,   0/4,   0/8 };
              ^
In file included from C:\Arduino\libraries\USB_Host_Shield_2.0/xboxEnums.h:21:0,
                 from C:\Arduino\libraries\USB_Host_Shield_2.0/XBOXUSB.h:23,
                 from XBOXUSB.ino:10:
C:\Arduino\libraries\USB_Host_Shield_2.0/controllerEnums.h:138:17: error: 'WHITE' redeclared as different kind of symbol
         WHITE = 9, // Available on the original Xbox controller
                 ^
In file included from C:\Arduino\libraries\FreetronicsOLED/FTOLED.h:58:0,
                 from XBOXUSB.ino:7:
C:\Arduino\libraries\FreetronicsOLED/FTOLED_Colours.h:12:14: error: previous declaration of 'const Colour WHITE'
 const Colour WHITE                = { 255/8, 255/4, 255/8 };
              ^
In file included from C:\Arduino\libraries\USB_Host_Shield_2.0/xboxEnums.h:21:0,
                 from C:\Arduino\libraries\USB_Host_Shield_2.0/XBOXUSB.h:23,
                 from XBOXUSB.ino:10:
C:\Arduino\libraries\USB_Host_Shield_2.0/controllerEnums.h:142:15: error: 'RED' redeclared as different kind of symbol
         RED = 0,
               ^
In file included from C:\Arduino\libraries\FreetronicsOLED/FTOLED.h:58:0,
                 from XBOXUSB.ino:7:
C:\Arduino\libraries\FreetronicsOLED/FTOLED_Colours.h:14:14: error: previous declaration of 'const Colour RED'
 const Colour RED                  = { 255/8,   0/4,   0/8 };
              ^
In file included from C:\Arduino\libraries\USB_Host_Shield_2.0/xboxEnums.h:21:0,
                 from C:\Arduino\libraries\USB_Host_Shield_2.0/XBOXUSB.h:23,
                 from XBOXUSB.ino:10:
C:\Arduino\libraries\USB_Host_Shield_2.0/controllerEnums.h:143:18: error: 'YELLOW' redeclared as different kind of symbol
         YELLOW = 1,
                  ^
In file included from C:\Arduino\libraries\FreetronicsOLED/FTOLED.h:58:0,
                 from XBOXUSB.ino:7:
C:\Arduino\libraries\FreetronicsOLED/FTOLED_Colours.h:102:14: error: previous declaration of 'const Colour YELLOW'
 const Colour YELLOW               = { 255/8, 255/4,   0/8 };
              ^
In file included from C:\Arduino\libraries\USB_Host_Shield_2.0/xboxEnums.h:21:0,
                 from C:\Arduino\libraries\USB_Host_Shield_2.0/XBOXUSB.h:23,
                 from XBOXUSB.ino:10:
C:\Arduino\libraries\USB_Host_Shield_2.0/controllerEnums.h:144:17: error: 'GREEN' redeclared as different kind of symbol
         GREEN = 2,
                 ^
In file included from C:\Arduino\libraries\FreetronicsOLED/FTOLED.h:58:0,
                 from XBOXUSB.ino:7:
C:\Arduino\libraries\FreetronicsOLED/FTOLED_Colours.h:15:14: error: previous declaration of 'const Colour GREEN'
 const Colour GREEN                = {   0/8, 255/4,   0/8 };
              ^
In file included from C:\Arduino\libraries\USB_Host_Shield_2.0/xboxEnums.h:21:0,
                 from C:\Arduino\libraries\USB_Host_Shield_2.0/XBOXUSB.h:23,
                 from XBOXUSB.ino:10:
C:\Arduino\libraries\USB_Host_Shield_2.0/controllerEnums.h:145:18: error: 'ORANGE' redeclared as different kind of symbol
         ORANGE = 3,
                  ^
In file included from C:\Arduino\libraries\FreetronicsOLED/FTOLED.h:58:0,
                 from XBOXUSB.ino:7:
C:\Arduino\libraries\FreetronicsOLED/FTOLED_Colours.h:123:14: error: previous declaration of 'const Colour ORANGE'
 const Colour ORANGE               = { 255/8, 165/4,   0/8 };
              ^
In file included from C:\Arduino\libraries\USB_Host_Shield_2.0/xboxEnums.h:21:0,
                 from C:\Arduino\libraries\USB_Host_Shield_2.0/XBOXUSB.h:23,
                 from XBOXUSB.ino:10:
C:\Arduino\libraries\USB_Host_Shield_2.0/controllerEnums.h:146:16: error: 'BLUE' redeclared as different kind of symbol
         BLUE = 4,
                ^
In file included from C:\Arduino\libraries\FreetronicsOLED/FTOLED.h:58:0,
                 from XBOXUSB.ino:7:
C:\Arduino\libraries\FreetronicsOLED/FTOLED_Colours.h:16:14: error: previous declaration of 'const Colour BLUE'
 const Colour BLUE                 = {   0/8,   0/4, 255/8 };
              ^
Error compiling.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: How do I deal with conflicting Libraries? Mainly Colour ENUMS

Post by angusgr » Thu Apr 30, 2015 7:10 am

Hi ChiggenWingz,

Sorry for the slow reply on this issue.

I just added a mechanism to the library for avoiding naming collisions with the predefined colour presets by disabling the FTOLED presets. You can see how to do this on the wiki:
https://github.com/freetronics/FTOLED/w ... collisions


Angus

Post Reply