I am a (very) white haired almost newby. I have a rather long sketch that sends information, instructions and advice to an Android device via bluetooth classic that acts as a more or less dumb display. This all works perfectly. At the moment the instructions etc. that are sent are held in PROGMEM to preserve space but I would like to remove this 'stuff' to a separate asset file in a separate tab to make adding/changing this stuff easier. I am not sure how to do this. I attach a sketch that shows what I have done to try and do this. Not surprisingly all that is returned is the first character in the relevant array entry. I am not sure how to declare the size of the array in the asset tab as well as declaring that the array entry will be an integer value. Can somebody give me a reference to help how to do all this. Should the asset file be a .c or .h or .ino? Many thanks.
Here are some print outs - I understand that both the main sketch and asset array are regarded as .ino files by the IDE.
(main sketch named: function_d)
const PROGMEM prog_char array1 [14] [10] {
{"q1y"}, {"q2yy"}, {"w3yyy"}, {"e4yyyy"}, {"r5yyyyy"}, {"t1y"}, {"z2yy"}, {"u3yyy"}, {"i4yyyy"}, {"o5yyyyy"}, {"p1y"}, {"a2yy"}, {"s3yyy"},
};
char arrayBuffer1[20];
void setup() {
int n;
Serial.begin(115200);
// using PROGMEM
Serial.println("trial with PROGMEM");
for (n = 0; n < 10; n++) {
memcpy_P (&arrayBuffer1, &array1 [n], sizeof arrayBuffer1);
Serial.println(arrayBuffer1);
}
// trying to use external asset tab
Serial.println("trial with external asset tab");
for (n = 0; n < 10; n++) {
Serial.println(asset2(n));
}
}
void loop() {
}
(Asset array in next tab named: assetArray)
char asset2(int x) {
char array2 [14] [10] = {
{"q1y"}, {"q2yy"}, {"w3yyy"}, {"e4yyyy"}, {"r5yyyyy"}, {"t1y"}, {"z2yy"}, {"u3yyy"}, {"i4yyyy"}, {"o5yyyyy"}, {"p1y"}, {"a2yy"}, {"s3yyy"},
};
Serial.print(array2 [x]); // check have we read the right stuff?
Serial.print(", ");
return *array2 [x];
}
(print out)
trial with PROGMEM
q1y
q2yy
w3yyy
e4yyyy
r5yyyyy
t1y
z2yy
u3yyy
i4yyyy
o5yyyyy
trial with external asset tab
q1y, q
q2yy, q
w3yyy, w
e4yyyy, e
r5yyyyy, r
t1y, t
z2yy, z
u3yyy, u
i4yyyy, i
o5yyyyy, o