Making two classes talk to each other: ADS1115 & EmonLib

EmonLib is a library used for calculating energy usage based on input from a current sensor

ADS1115 is a library used for interfacing with an analog to digital break out board.

The problem with EmonLib is that it assumes that the current sensor is wired directly to the Arduino. In setup, you call it like this: emon1.current(A1, 111.1);            // Current: input pin, calibration. Notice that in this example you are giving 1 as the analog input pin. The class uses analogRead(pin).

Instead I need it to use the ADS1115 library's readADC_SingleEnded method to read the analog value from the breakout board.

My thought was to modify emonlib's class so that it accepts an instance of the ADS class, but I cannot for the life of me figure out how to do make it work.

How do you write a method declaration so that it accepts the instance of an object as an argument?

I tried:
void current(unsigned int _inPinI, double _ICAL, Adafruit_ADS1115& _ads);
hoping that it would allow me to pass an instance of the ADS class as the third arugment to this method, but I get a compilation error: error: 'Adafruit_ADS1115' has not been declared

The adafruit class is included before the emonlib class in my sketch.

Help! :slight_smile: