I'm using a list class that I created to keep track of points. Unfortunately, I've found that the second I instantiate two of these lists my board will silently crash.
This code works.
#include <Point.h>
#include <PointList.h>
PointList test;
setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("We Made It");
}
But this one silently fails, it never makes it to setup or loop.
#include <Point.h>
#include <PointList.h>
PointList test;
PointList test2;
setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("We Made It");
}
Lastly, in case it is important here is the List library.
PointList.cpp
#include "Point.h"
#include "PointList.h"
#include "Arduino.h"
PointList::PointList() {
length = 0;
for(int i = 0; i < 512; i++) {
values[i] = Point(0,0,0);
}
}
void PointList::add(Point point) {
length++;
values[length - 1] = point;
}
Point PointList::get(int index) {
if(index > length) {
Serial.println("Error: Index exceeds bounds of list");
return Point(6,6,6);
}
return values[index];
}
void PointList::remove(int index) {
length--;
for(int i = index; i < length; i++) {
values[i] = values [i +1];
}
}
PointList.h
#ifndef PointList_h
#define PointList_h
#include "Arduino.h"
#include "Point.h"
class PointList {
public:
int length;
Point values[512];
PointList();
void add(Point led);
Point get(int index);
void remove(int index);
};
#endif