Hi,
I want to read an ascii image file and display it line by line on a WS2812 strip (it's a kind of 1D movie!). Since there won't be enough memory to load all of the file at once, I tried to write a class that handles the reading for me; it opens the file and stores 1 row) in an array every time i call the nextline() method. Here is a part of my code, it should suffice to hint at how I tried to do it:
class PPMfile
{
public:
PPMfile() { rowsleft = 0; };
~PPMfile() {};
bool open(char *filename);
bool nextline();
void close();
byte size() const { return cols; }
byte pixel(unsigned int n, byte rgb) const{ return (n<0||n>cols||rgb<0||rgb>2?0:pixels[n][rgb]); };
byte operator()(unsigned int n, byte rgb) const { return pixel(n, rgb); };
private:
File dataFile; // File *dataFile fails as well
unsigned int rows, cols, rowsleft;
byte pixels[NUMPIXELS][3]; // this is another workaround - new and malloc don't work as expected
};
My idea didn't compile - and I was able to reduce the problem to a simple sketch:
#include <FileIO.h>
void setup()
{
Bridge.begin();
FileSystem.begin();
File test;
test = FileSystem.open("test");
}
void loop()
{
// don't do anything
}
The error message is
/home/walter/Dropbox/dev/arduino/arduino-1.5.5_64/libraries/Bridge/src/FileIO.h: In member function ‘File& File::operator=(const File&)’:
/home/walter/Dropbox/dev/arduino/arduino-1.5.5_64/libraries/Bridge/src/FileIO.h:28: error: non-static reference member ‘BridgeClass& File::bridge’, can't use default assignment operator
sketch_test.ino: In function ‘void setup()’:
sketch_test.ino:8: note: synthesized method ‘File& File::operator=(const File&)’ first required here
I know that File test= FileSystem.open("test"); would work, but that's the point: I need to declare File test outside the function/method that FilesSystem.opens the file.
Is there any bugfix/alternative/workaround for this? Am I the only person that wants to read files portion by portion using functions/classes?
Thanks
Walter