int digits = millis()/10000;
int digchk = digits;
switch (digchk) {
case 5: { if (digchk<10000) { GLCD.print('0'); }}
case 4: { if (digchk<1000) { GLCD.print('00'); }}
case 3: { if (digchk<100) { GLCD.print('000'); }}
case 2: { if (digchk<10) { GLCD.print('0000'); }}
}
GLCD.print(digits);
//digchk = 0;
EDIT: Got it.
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
GLCD.CursorTo(0, 1);
// print the number of seconds since reset:
int digits = millis()/10000;
int digchk = digits;
switch (digchk) {
case 5: { if (digchk<10000) { GLCD.print('0'); }}
case 4: { if (digchk<1000) { GLCD.print('00'); }}
case 3: { if (digchk<100) { GLCD.print('000'); }}
case 2: { if (digchk<10) { GLCD.print('0000'); }}
}
GLCD.print(digits);
}
I don't get what this means:
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
GLCD.CursorTo(0, 1);
There isn't a cursor on the screen. Can someone explain?
EDIT: ah ok, the second row on the screen is where text will start...
Well, I guess the terminology used in glcd may be a bit confusing.
While there is no visible cursor shown on the glcd display, there is a cursor position.
The next printed character on the glcd in the text area will be at the current
cursor position for the text area (each text area has its own "cursor" position).
Does that make sense?
You can think of glcd as having an "invisible" cursor.
One thing to take note of is that if you intend to overwrite the numbers with a new
set of numbers, you must to use a fixed width font. Otherwise even though there may
be the same number of digits printing, the overall width in pixels of all the digits
may not be the same. This is because with most proportional fonts, the digits are not
all the same width in pixels.
BTW, the glcd library supports xxprintf() formatting so if you want you can use
GLCD.Printf() to format your output strings. It will cost you about 1.5-1.8k of flash space
but it makes formatting really easy and is very easy to update/modify the formating.
i.e.
GLCD.Printf("%05d", millis()/1000); // print number of seconds since reset as 5 zero filled digits
GLCD.Printf("%5d", millis()/1000); // print number of seconds since reset as 5 right adjusted digits
should do what you wanted in your example.
See the BigNums example for other Printf examples and some examples of how
to use glcd text areas.