Tried putting all classes into their own hpp and cpp files, but somehow getting the following errors when using them
(first time using cpp and feel like thats the issue)
build/Main.o: in function `Controls::Controls()':
Main.cpp:39: undefined reference to `Controls::Switches'
Main.cpp:39: undefined reference to `Controls::Switches'
Main.cpp:39: undefined reference to `Controls::Switches'
Main.cpp:39: undefined reference to `Controls::Switches'
Main.cpp:39: undefined reference to `Controls::Switches'
Main.cpp:39: undefined reference to `Controls::encoder'
Main.cpp:39: undefined reference to `Controls::led'
Main.cpp:39: undefined reference to `Controls::Switches'
broken down all the files to only include whats needed to debug
Main.cpp
#include "Controls.hpp"
static Controls input;
Controls.hpp
#pragma once
#include "daisy_seed.h"
using namespace daisy;
class Controls
{
protected:
static Switch Switches[3][5];
static Encoder encoder;
static RgbLed led;
public:
Controls();
};
Controls.cpp
#include "Controls.hpp"
#include "daisy_seed.h"
using namespace daisy::seed;
Controls::Controls() {
Switches[0][0].Init(D30); // Lower Row Left
Switches[0][1].Init(D26);
Switches[0][2].Init(D22);
Switches[0][3].Init(D18);
Switches[0][4].Init(D17); // Lower Row Right
Switches[1][0].Init(D6); // Upper Row Left
Switches[1][1].Init(D7);
Switches[1][2].Init(D8);
Switches[1][3].Init(D12);
Switches[1][4].Init(D13); // Upper Row Right
Switches[2][0].Init(D14); // Extra Left
Switches[2][1].Init(D15); // Extra Right
encoder.Init(D0, D2, D1);
led.Init(D9, D10, D11, true);
}
Makefile
# Project Name
TARGET = ex_Looper
# Sources
CPP_SOURCES = Helper.cpp Controls.cpp Main.cpp
# the compiler: gcc for C program, define as g++ for C++
CC = g++
# Library Locations
LIBDAISY_DIR = ../../libDaisy
DAISYSP_DIR = ../../DaisySP
# Core location, and generic makefile.
SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core
include $(SYSTEM_FILES_DIR)/Makefile