I'm trying to use Adafruit's LED Backpack library within a custom class. When I use the Adafruit library directly within a sketch, it compiles fine. When I use an example sketch provided with the library, it compiles fine. However when I create an instance of my custom class with the Adafruit object within it, I get the following error:
In file included from sketch_feb18a.ino:6: /Users/lawnmowerlatte/Documents/Arduino/libraries/Bargraph/bargraph.h:18: error: 'Adafruit_24bargraph' does not name a type
All the reasons I've seen for this error stem from the library being missing or otherwise incorrectly installed. However, since I can use it directly, I think something else must be wrong.
Working
#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
Adafruit_24bargraph bar = Adafruit_24bargraph();
void setup() { }
void loop() { }
Not Working
#include <bargraph.h>
Bargraph bargraph = Bargraph("Test", "api", 0);
void setup() { }
void loop() { }
bargraph.h
#ifndef Bargraph_h
#define Bargraph_h
#include <Adafruit_GFX.h>
#include <Adafruit_LEDBackpack.h>
#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
class Bargraph {
public :
String name;
String api;
Adafruit_24bargraph bar;
Bargraph(String _name, String _api, int _device,
String _type="Default");
void set(String _value);
void setMax(String _max);
void update();
void print();
private :
int display[24];
long max;
long value;
int device;
int size;
String type;
void format();
void write();
};
#endif
bargraph.cpp
#define OFF 0
#define RED 1
#define YELLOW 2
#define GREEN 3
#include <bargraph.h>
#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
Bargraph::Bargraph(String _name, String _api, int _device, String _type) : bar() {
name = _name;
api = _api;
max = _max.toLong();
device = _device;
type = _type;
value = 0;
for (int i=0; i<24; i++) {
display[i] = OFF;
}
bar.begin(0x70+device);
}
**Methods Omitted for Brevity**
Can anyone explain what's going on here? I'm pretty certain my class syntax is correct as I have other object-in-object relationships working. I can post code to GitHub if anyone would like to see more context.