OK, this is just mad.
First change, added:
lcd.print("hello world");
delay(10000);
to setup(). That was displayed just fine.
Next I removed the Serial.println("");, but now the "hello world" message gets displayed but the first two characters are corrupted, but the time gets displayed OK.
Almost seems like there is a buffer that is being created but not initialised correctly.
Here is the current state of my code:
#include <LiquidCrystal.h>
#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h>
int rtc[7];
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
// Uncomment these lines if you want to set the time on startup
/*
RTC.stop();
RTC.set(DS1307_SEC,0);
RTC.set(DS1307_MIN,26);
RTC.set(DS1307_HR,15);
RTC.set(DS1307_DOW,6);
RTC.set(DS1307_DATE,29);
RTC.set(DS1307_MTH,11);
RTC.set(DS1307_YR,9);
RTC.start();
*/
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
lcd.print("hello world");
delay(10000);
}
char* dayOfWeek[] = {"xxx", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
void loop()
{
RTC.get(rtc,true);
lcd.setCursor(0,0);
//lcd.print(millis());
printDigits(rtc[2],':');
printDigits(rtc[1],':');
printDigits(rtc[0],' ');
lcd.print(dayOfWeek[rtc[3]]);
lcd.setCursor(0,1);
printDigits(rtc[4],'/');
printDigits(rtc[5],'/');
printDigits(rtc[6],' ');
//Serial.println("");
delay(100);
}
void printDigits(int digits, char delimiter)
{
if(digits < 10) {
lcd.print('0');
}
lcd.print(digits,DEC);
lcd.print(delimiter);
}
If I change "hello world" to ".", it displays a double bar symbol for 10 seconds, then the dayOfWeek is corrupted and becomes a double bar. If I change it to ".,", then I get two corrupt characters for 10 seconds then the main loop displays mostly garbage which bears a slight resemblance to the time and date. ".,/" goes back to a basically blank screen. "hello" performs the same as "hello world".
This is insane!
I think I'm going to try using a different computer, I'm wondering if there is an incompatibility with W7x64 RC1 somewhere. I'll give it a go on my XP based netbook tomorrow sometime. The fact that adding or removing code from loop() is affecting code running in setup() just strikes me as ridiculous unless there is a compiler problem/incompatibility somewhere.