I'm developing application using LCD Keypad (from DFRobot), including LiquidCrystal library. My projects includes some small hierachy of classes, responsible for displaying particular pages, something like: BasePage->SomePage... Problem i'm facing right now is that if i use in SomeClass array of strings (char* values[NUMBER] or String values[NUMBER]) displayed strings are corruped (overwritten by others strings) or completly unknown signs on display. Some overwiew for the code:
class BasePage
{
String line1; // LCD line 1
String line2; // LCD line 2
};
class SomePage : public BasePage
{
String values[NUMBER];
// ...or...
char* values[NUMBER];
};
I've few such pages (derrived from BasePage), each one initiated line1 and line2, but whe i use array of strings in some derrived class there is corruption of line1 or line2 (or both). I've tried also global array (outside of class) and PROGMEM directive, the same result. Could you see any problem here? Could it be lack of RAM memory?
If you are using char pointers, you need to make sure that you are allocating space for the string. Pointers are wonderful things, and, when properly allocated, equivalent to char arrays. When not properly allocated, though, they are rubbish, and will allow you to screw all kinds of stuff up.
I've changed all my strings in program to such defines and each one is placed in global include file. I've removed usiage of String type (char* only). Page objects are initiated like this:
Problem solved for now, i've removed all calls related to String type and it helped, for char* strings everything is working. As one colleague said above, maybe this is really problem of String type.