Trouble creating new Terrarium class from DaisyPod class

I’d like to modify the DaisyPod class in libDaisy to create a class for the PedalPCB Terrarium. All I did was copy the daisy_pod.cpp/.h files in the same folder, rename the class, add additional pins, remove some irrelevant functions, and add more knob/switch objects, changing the names to make more sense for this hardware. VSCode doesn’t show any errors or missing references.

For some reason when I try to compile an example using this new class via the build_all task, I get errors saying “undefined reference to daisy::Terrarium::Init(bool)” and all other functions that are called from the new Terrarium class.

I can’t seem to find any issues with the code and I was hoping someone could tell me why the compiler seemingly is missing things from the header file that I made sure to include. Attached are the daisy_terrarium header/source files and the default passthrough example I’m trying to run. I get the feeling this is an obvious mistake to someone more familiar with coding, would greatly appreciate any help.

TerrariumFiles.zip (323.0 KB)

The Terrarium.* files should be in the same folder as your Makefile. Currently, they are one folder up.
The CPP_SOURCES should include terrarium.cpp:

CPP_SOURCES = controlstest.cpp terrarium.cpp

That doesn’t address the question, which was about creating a new class for Terrarium. Whether that is a useful or worthwhile project is another matter.

What about it would be not worthwhile? The DaisyPod class works well for programming with the Pod dev board, I don’t see how the Terrarium is any different. Any ideas why DaisyPod works but Terrarium doesn’t?

I added the daisy_terrarium files to the makefile/CMakeLists.txt in the main libDaisy folder but it’s still not working.

It’s easy enough to program Terrarium without making a change in the libDaisy source code.

But, I also agree, a proper class would be preferable to the way Pedalpcb did it, which is sort of Petal-based.
I just prefer not modifying ‘supplied’ code, just like I don’t modify factory installed header files and libs on Linux or Mac.

I ran into a similar issue of wanting to create a custom hardware definition. I got it working by:

  • Duplicating the .cpp and .h files of one of the existing hardware definitions in libDaisy/src.
  • renaming the files, class and changing the file however I needed. The files are kept in libDaisy/src alongside the other hardware definiitions.
  • Adding the new file name to the list of CPP_MODULES in the libDaisy top level makefile.
  • Running ‘make’ in the libDaisy folder.
  • Running ‘make’ on the project that you are trying to build.

Running make on the project that uses the hardware definition isn’t enough, you have to make libDaisy every time you make a change to the hardware definition files. I only just did this but it seems to work.

1 Like