Hey, I have recently attempted to make a library which enables users to put a scrolling text command along with their AXE133Y Picaxe OLED display, here is the header code:
#ifndef ScrollText_h
#define ScrollText_h
#include "Arduino.h"
#include <AXE133Y.h>
class ScrollText
{
public:
scroll(String input);
String input;
private:
String _input;
int _blank;
String _output;
String _output2;
int _amount;
char _charBbuf[];
int _pos;
int _poss;
};
#endif
And here is the .cpp file:
#include "Arduino.h"
#include "ScrollText.h"
#include <AXE133Y.h>
AXE133Y OLED = AXE133Y(1);
void ScrollText::scroll(String input)
{
String _input = input;
for (int _blank = 16; _blank > 0; _blank--)
{
String _output = "";
String _output2 = "";
for(int _amount = _blank; _amount >= 0; _amount--)
{
_output = _output + " ";
}
for (int _amount = 16 - _blank; _amount >= 0; _amount--)
{
_output2 = _output2 + " ";
}
_output = _output + _input + _output2;
OLED.cursorHome(1);
OLED.print(_output);
delay(150);
}
OLED.cursorHome(1);
OLED.print(" " + _input + " ");
OLED.cursorHome(1);
delay(170);
char _charBuf[_input.length()];
_input.toCharArray(_charBuf, _input.length() + 1);
for (int _pos = 0; _pos <= _input.length(); _pos++)
{
OLED.cursorHome(1);
for(int _poss = _pos; _poss <= _input.length(); _poss++)
{
OLED.print(String(_charBuf[_poss]));
}
OLED.print(" ");
delay(150 + (_input.length() / 1.5));
}
OLED.clearScreen();
}
I can't find any errors with this, yet when I put this code into the Ardunio IDE:
#include <ScrollText.h>
void setup()
{
ScrollText.scroll("Hello World");
}
void loop()
{
}
It returns the following errors:
"In file included from sketch_feb06a.ino:1:
C:\file system etc... \arduino\libraries\ScrollText/ScrollText.h:14: error: ISO C++ forbids declaration of 'scroll' with no type
sketch_feb06a.ino: In function 'void setup()':
sketch_feb06a:5: error: expected unqualified-id before '.' token"
Can anyone tell me why this is happening and how I can fix it? Cheers in advance!
Tom C (15)