Particle Build vs Dev and the MAX17043 library

I’m using Particle Dev for my latest project and I started to add on a Photon Battery Shield. I added the MAX17043 libraries to my folder and pasted in the code from the example. It threw an error at lipo.begin() - “lipo was not declared in this scope”.

So I went back to basics. I created a new folder which has only four files: test.ino, SparkFunMAX17043.h, SparkFunMAX17043.cpp and MAX17043_Definitions.

test.ino is a cut and paste of the MAX17043_SIMPLE.ino from Particle Build (which works fine). The include statement was changed from

#include "SparkFunMAX17043/SparkFunMAX17043.h" 

to

#include "SparkFunMAX17043.h"

Other than that, all the files are identical. It runs on Particle Build but not on Particle Dev.

I presume “lipo” is an instance of the class defined in SparkFunMAX17043.h. I can’t actually find where it is defined and there is no mention of “lipo” in any of the included files so I’m not surprised that it throws an error. But I don’t know why it runs on Particle Build or how to get it to run on Dev. Does Build have access to some other info or file?

Obviously I am not understanding something pretty basic. (Sorry).

This is the last line in the header file

extern MAX17043 lipo;

And this the last line in CPP

// Define a static MAX17043 object called lipo, which we'll use in the sketches.
MAX17043 lipo;

Are you sure you copy-pasted the entire contents of all the files?

BTW: You could go to the library repo (by clicking on the GitHub icon next to the lib name) and download the ZIP file of it. This way you will definetly have the complete files.

Thanks ScruffR. You are my lifeline for all things Photon. You have identified the problem.

You are correct that “lipo” is defined in the header of the online version (i.e Build). I was using the SparkFunMAX17043 library files from Photon_Stack_Demo-master.zip.

In these files the definition is

extern MAX17043 gauge;

Things are defined differently between the online Build example (“lipo”) and the GitHub files (“gauge”). I should have caught that. It now makes sense that including the GitHub libraries in Dev and cutting and pasting from the online example didn’t work.

2 Likes