Hello, I'm an old newbie to c++ , so sorry if question sounds stupid
I'm trying to save some ram by reusing an array
This does not compile :
// declaring the array
byte myChar[8] = {
B00000,
B10001,
B00000,
B00000,
B10001,
B01110,
B00000,
B00000
};
lcd.createChar(0, myChar);
//attempt to refill that same array , but it fails
myChar[8] = {
B00000,
B10001,
B00100,
B00000,
B10001,
B01110,
B00100,
B00000
};
lcd.createChar(1, myChar);
Since , - I believe - every time I write " byte araynam[8] {} " I lose 8 byte in RAM I toucht why not resuse 1 array and fill it up again esaily just like I declared it.
Of course I could go through every element in the array by using its indexnr between the [] and do an assign but that does not look fine.
You are right. You cannot define the contents of the array like that a second time. You need to set each element individually, perhaps by copying from another array element by element or using memcpy() to copy the whole of another array.
Hey UKHeliBob, I was afraid for this that there would not be an "proper" second chance to reassign the values.
I'll try to do a memcpy from a const array, see if that works. Thanks for the tip.
Maybe even better would be that I could rewrite the lcd.createchar function in
such way that I could enter the 8 elements in the function call, but in C++ , I have
no doubt how to do that. Got lots of learning to do
Be aware that if you define a character and display it then if it is still on the display when you redefine it then the character already displayed will change as well.