Thanks for your prompt replies, here is the code:
MSFTime MSF;// = MSFTime();
time_t msfTimeSync();
byte prevStatus = 255;
void setup() // run once, when the sketch starts
{
Serial.begin(9600);
LedSign::Init(GRAYSCALE);
MSF.init( 255 ); // LED pin for status
setSyncProvider(msfTimeSync); // tell the Time library what to ask for a new time value
}
time_t msfTimeSync() // called periodically by Time library to syncronise itself
{
return MSF.getTime();
}
void drawLine( int offset, int val, int range )
{
int total = 9;
val = val%range;
int at = ( val * total ) / range;
for( int i =0; i < at-1; i ++ )
LedSign::Set(i,offset, 1);
LedSign::Set(at-1, offset, 3);
}
int offset = 13;
void loop() // run over and over again
{
LedSign::Clear();
//drawLine( 0, 7, 8);
char buff[20];
now(); // make sure Time has attempted to sync
byte currStatus = MSF.getStatus();
#define MESSAGE_LEN 20
char test[MESSAGE_LEN];
int chars =0;
if( timeStatus() == timeNotSet )
{
if( ! (currStatus & MSF_STATUS_CARRIER))
chars = sprintf( test, "NO CARRIER ");
else if( (currStatus & MSF_STATUS_WAITING))
{
drawLine( 8, MSF.getProgess(), 60 );
chars = sprintf( test, "WAITING ");
}
else if( (currStatus & MSF_STATUS_READING))
{
drawLine( 8, MSF.getProgess(), 60 );
chars = sprintf( test, "READING ");
}
else
chars = sprintf( test, "CONFUSED "); // should never happen
}
else
{
int mins = MSF.getFixAge()/60000L;
if( mins < 0 )
mins = 0;
drawLine( 8, mins, 14 ); // fix age, one LED per min
chars = sprintf( test, "%02d:%02d:%02d %02d:%02d:%04d ", hour(), minute(), second(), day(), month(), year() );
}
int8_t x, x2;
x = offset;
for(int i=0;i<chars;i++)
{
x2=Font::Draw(test[i],x,0,3);
x+=x2;
if (x>=13) break;
}
if( x >= 13 )
offset --; // there was more stuff to draw off the right, keep scrolling
else
offset = 13; // set the scroll back to draw at the right of the screen
delay(80);
}