The code is riddled with delays(), I count about 2.5 seconds for each invocation of getMsgText() during which time nothing is happening.
I don't know if that's the problem but it can't help.
I went in and tweaked the delays a little bit, but the ones that remain are to control the speed of the text appearing on the LCD and the speed of the scrolling.
How often does the Android send messages?
From what I can tell, it pops a new message up/over to the arduino whenever the
meetAndroid.receive command is reached in the main loop on the Arduino side.
What does meetAndroid.receive() do?
This is how I believe it works:
When the android app (see Android code below) reaches the
Amarino.sendDataToArduino(this, DEVICE_ADDRESS, 'z', oneMessage); statement, it makes one string (in this case it's a string, but it could be int, float, or whatever) available to the Arduino, by either loading it to the Arduino or by notifying the Arduino that it has a string ready and available (I'm not sure which), doing this via the
meetAndroid.receive statement on the Arduino side. Along with the string is sent a flag (in this case it's a 'z') which the
meetAndroid.receive statement uses to trigger the registered function associated with that flag, which here is the
getMsgText function. The
getMsagText function triggers, at some point executing the
getString statement, which grabs the string and places it into the array
msgText. At some point within or at the end of these steps, the
Amarino.sendDataToArduino of the Android app makes another string available (if there are more) to the Arduino and the cycle continues.
Java function that sends an array of strings to the Arduino one at a time:
private void messagesToArduino(ArrayList<message> messagesToDisplay) {
int numMsgs = messagesToDisplay.size();
String oneMessage;
for (int i = 0; i < numMsgs; i++) {
oneMessage = messagesToDisplay.get(i).message;
Amarino.sendDataToArduino(this, DEVICE_ADDRESS, 'z', oneMessage);
}
}
Does this give you any ideas where it (or I) might be falling down?