... separate pieces:
lcd.print( val );
lcd.print( F(" ") );
I used String because I think a lcd.print(String...) is faster
Actually, the same number of characters get written to the LCD with either technique. The transfer time is the same.
However, constructing a String object and concatenating it with another piece actually takes much longer than calling print twice.
In e_Menu1 you declare:
extern void Coordinate();
extern void BattVolt();
I didn't do it, but it was working...?
Yes, when you have many INO files in the sketch directory, the IDE concatenates them into one big file. Sometimes, the order of that concatenation causes an error like "Coordinate not declared." Those simple "extern" statements are called "forward declarations".
I added a routine, DisplayLimiti, and it caused several of these errors. I tried removing them, and it compiles ok. You can try removing any or all of them.
You may eventually want to have one INO file (Limiti.ino) and multiple H (declarations) and CPP (executable code) files. Multiple INO files are ok.
What is the difference using print(' ') instead of print(" ")?
The single apostrophe is for one character literals or constants, like one space character ' '. This is the char
type.
The double quote is for multiple-character strings, like "ABC". This is actually an array, char []
, also called "C strings". This is not the [u]S[/u]tring
class.
When you use a double-quoted string, the compiler makes a "secret" array out of it, and also puts a zero byte after the last character. This is called the "NUL terminator".
Any routine that receives a C string (like print
) needs to know the length of this string. In the case of lcd.print
, it prints each character in the array, until it sees a zero character. Then it stops.
So when you write this code:
lcd.print( "ABC" );
The compiler generates this for you:
char secretArray[ 4 ] = { 65, 66, 67, 0 };
lcd.print( secretArray );
When you print a single character, there is no extra zero byte, and the print routine does not loop through multiple characters.
The single character print is a little faster and uses a little less program space than the double-quoted string print. It's not a big difference, but it can help when there are a lot of them, and you're short on space.
I have had to do 3 little corrections
Sorry, I am glad you were able to find them easily!
the plug icon was never drawn.
There was one place that I replaced a write(byte(0))
with a print(' ')
. I thought you were trying to print the NUL terminator. My mistake. Check line 13 of j_orae_data.INO, I think it should be:
lcd.write( byte(0) );
Also, I would suggest giving names to these special characters in Limiti.ino:
const byte NO_FIX_ICON = 0;
const byte DEGREE_ICON = 1;
const byte CHARGE_ICON = 2;
const byte DIR_ICON = 3;
const byte BATTERY_ICON = 4;
Then it's obvious what is being printed:
lcd.write( NO_FIX_ICON );
One last thing... I was not sure about the lat/lon display format you wanted. I only displayed the degrees format, like 41.890178, 12.492274. These are floating-point degrees, not Degrees-Minutes-Seconds. They are positive for N and E and negative for S and W. I did not display the DEGREE_ICON.
Did you also want a DMS display? Some paper maps have DMS grids.
The DDMM.mmmm format is not very useful, are you sure you want that? It is the raw NMEA format, but it is not used on any maps that I have seen.
Also, I changed some delay
calls to a while
loop. This keeps the GPS fix updated and avoids losing any GPS characters:
while ((millis() - t1 < 500) || (digitalRead(10)==LOW))
{
if (GPS.available( gpsSerial ))
fix = GPS.read();
}
You may want to make a new routine that can be called from all of these places:
bool checkGPS()
{
bool newData = GPS.available( GPSserial );
if (newData)
fix = GPS.read(); // get the latest
return newData;
}
Then you can use it everywhere, like this:
while ((millis() - t1 < 500) || (digitalRead(10)==LOW))
{
checkGPS();
}
Cheers,
/dev